make me a roblox luau script that does this When some hits me, i will get a juju…
- User
make me a roblox luau script that does this When some hits me, i will get a juju notification saying something like " () Has hit you for damage" and then " () Has killed you"
DONT ADD THE TAB
Elements Here is an explanation of menu elements and their respected properties.
Creating a Tab To start adding your own elements, you must create a tab using juju.create_tab; shown below.
Copy juju.create_tab(name: String) Argument Type Description name
String
The tab's name, providing no name will default it to the addon's file name
Creating Sections To create a section, you must create a section using juju.create_section; this will error if a tab is not created beforehand.
Copy juju.create_section(name: String, size: Number, side: Number, offset: Number) Argument Type Description name
String
The section's name
side
Number
The side the section will be placed on in the tab, 1 = left, 2 = light
size
Number
The vertical size of the section (0.1-1)
offset
Number
The vertical offset of the section (0-0.9)
Creating Elements To create a section, you must create a section using juju.create_element.
When using juju.create_element there is an argument labeled types. Below is a fully working addon example of how to properly set up this argument.
Copy juju.create_tab() juju.create_section("example_section", 1, 1, 0)
juju["create_element"]("example_section", { ["name"] = "example colorpicker" }, { ["colorpicker"] = { ["color_flag"] = "example_color", ["default_color"] = Color3.fromRGB(0,255,0), ["transparency_flag"] = "example_transparency", ["default_transparency"] = 0 } })
Element Properties Each type of element has unique properties that you can assign them when creating; and this page lists them all.
Toggle Argument Type Description default
Boolean
The default state of the toggle
flag
String
The flag assigned to the toggle value
Slider Argument Type Description min_text
String
The text the slider displays when the slider's value is the lowest possible
max_text
String
The text the slider displays when the slider's value is maxxed out
decimals
Number
The decimal amount used in slider value (1 = first decimal place, and so on)
default
Number
The default value of the slider
prefix
String
The text that shows before the value in the menu
suffix
String
The text that shows after the value in the menu
flag
String
The flag assigned to the slider value
min
Number
The minimum value allowed to set the slider to
max
Number
The maximum value allowed to set the slider to
Dropdown Argument Type Description default
Table
The default options to be selected
options
Table
The options available in the dropdown
requires_one
Boolean
Whether or not the dropdown selection can be none
multi
Boolean
Whether or not multiple options can be selected
flag
String
The flag assigned to the dropdown selected options
Colorpicker Argument Type Description default_transparency
Number
The default transparency of the colorpicker
transparency_flag
String
The flag assigned to the transparency value
default_color
Color3
The default color of the colorpicker
color_flag
String
The flag assigned to the color value
Textbox Argument Type Description default
String
The default value of the textbox
flag
String
The flag assigned to the textbox value
Button Argument Type Description confirmation
Boolean
Whether or not the button must be clicked twice (confirmed) to activate, like seen with the load and save config buttons
Element API Each signal is fired when a new value is set to an element, some may not if the second argument to the setting function is true.
Copy element:create_settings() Returns Type Description section (copy)
Table
This creates a fake section openable by the cog icon next to your element label. This fake section's create_element function has identical functionality to juju.create_element, just without the section name arg.
Copy element:set_visible(visible: Boolean) Returns Description None
N/A
Toggle Signal Description on_toggle_change
This signal is fired the first argument being the new value of the toggle
Function Return Type Description set_toggle
None
Sets the toggle state to the first argument
Copy local void_hide = juju"find_element"
local connection = juju["create_connection"](void_hide["on_toggle_change"], function(bool) print(bool) -- will print true after it is set below, unless void hide- -- is already on in which case this signal will not fire end)
void_hide:set_toggle(true) Slider Signal Description on_slider_change
This signal is fired the first argument being the new value of the slider
Function Return Type Description set_slider
Number
Sets the slider value to the first argument
Dropdown Signal Description on_dropdown_change
This signal is fired the first argument being the new value of the dropdown
Function Return Type Description set_dropdown
None
Sets the selected dropdown options to the first argument
set_options
None
Sets the dropdown's available options to the first argument
Colorpicker Signal Description on_transparency_change
This signal is fired with the first argument being the new transparency of the colorpicker
on_color_change
This signal is fired with the first argument being the new color of the colorpicker
Function Return Type Description set_colorpicker_transparency
None
Sets the colorpicker transparency to the first argument
set_colorpicker
None
Sets the colorpicker color to the first argument
Textbox Signal Description on_textbox_change
This signal is fired with the first argument being the new value of the textbox
Function Return Type Description set_textbox
None
Sets the textbox value to the first argument
Button Signal Description on_clicked
This signal is fired when the button is clicked in the menu
Utility Functions Here is a list of the available functions used to assist script developers
Copy juju.on_unload(callback: Function) Argument Type Description callback
Function
This function is called when the addon is unloaded
Copy juju.create_connection(signal: RBXScriptConnection or Table, callback: Function) Argument Type Description signal
RBXScriptSignal or table (custom signals)
The signal to connect the callback to
callback
Function
The function to connect to the signal
Return Type Description RBXScriptSignal or table (custom signals)
Signal object, can use :Disconnect etc
Copy juju.find_element(section: String, feature: String) Return Type Description Table
An element, like given from create_element
If you are attempting to access a feature within an element's settings, use the element/feature as the parent name instead of the section. Also, this is an expensive function; it is recommended to only use this during initialization.
Example: juju.find_element("ragebot", "void hide")
Copy juju.get_flags() Return Type Description Table
A table holding the names of all juju flags
Copy juju.get_flag(flag: String) Return Type Description Any
The value of the flag given
Copy juju.set_flag(flag: String, value: Any) Return Type Description None
N/A
Copy juju.get_signals() Return Type Description Table
A table holding the names of all juju signals
Copy juju.get_signal(name: String) Return Type Description Table / RBXScriptSignal
The found signal
This, along with some other functions may not error if the function failed to complete. If the signal does not exist, this function will not error. It is recommended you complete these sort of checks your self.
Copy juju.create_notification(text: String, type: Number, time: Number) Argument Type Description text
String
The text that will be displayed over the notification
type
Number
The type of notification being sent, 1 = Success, 2 = Alert, 3 = Fail
time
Number
The amount of time the notification is on screen (0.5 - 7 seconds only)
Copy juju.set_player_status(player: Instance (Player), status: Number) Argument Type Description player
Instance (Player)
The player that will have their status set
status
Number
The status the player is being set as, 1 = Neutral, 2 = Friendly, 3 = Enemy
Copy juju.get_player_status(player: Instance(Player)) Return Type Description Number
The player's current status, 1 = Neutral, 2 = Friendly, 3 = Enemy
Copy juju.get_active_keybinds() Return Type Description Table
Example return result: {["silent aim"] = true, ["prediction"] = 1948.6923814}
Copy juju.load_config(name: String) Argument Description name
The name of the config, without the extension. default.cfg -> juju.load_config("default")
example script 1:
local juju = juju -- This is not neccessary. local create_connection = juju["create_connection"] local create_notification = juju["create_notification"] local players_service = cloneref(game:GetService("Players")) local player_image_data = base64_decode("") local do_join_notification = function(player) create_notification(player["Name"].." has joined the server!", 2) end local do_leave_notification = function(player) create_notification(player["Name"].." has left the server!", 2) end -- >> ui toggle local example_toggle = juju["create_element"]({ ["name"] = "player join logs" }, { ["toggle"] = { flag = "example", default = false } }) -- >> core local example_connection2 = nil local example_connection = nil create_connection(example_toggle["on_toggle_change"], function(bool) if example_connection then example_connection:Disconnect() example_connection = nil end if example_connection2 then example_connection2:Disconnect() example_connection2 = nil end if bool then example_connection = create_connection(players_service["PlayerAdded"], do_join_notification) example_connection2 = create_connection(players_service["PlayerRemoving"], do_leave_notification) end end) -- >> clean up juju["on_unload"](function() print("bye bye :(") -- Notice we don't need to disconnect our connections above since we -- used juju's built in create_connection function! end)example script 2:
-- >> variables local juju = juju local get_flag = juju["get_flag"] local delay = task["delay"] -- >> core local twod_hit_marker = juju["find_element"]("2d hit marker", "color") local threed_hit_marker = juju["find_element"]("3d hit marker", "color") local set_old = function(d2, d3) twod_hit_marker:set_colorpicker(d2) threed_hit_marker:set_colorpicker(d3) end local hit_callback = function(player, part) if part["Name"] == "Head" then local color = get_flag("hit_marker_headshot_color") local old_d2_color = get_flag("d2_hit_marker_color") local old_d3_color = get_flag("d3_hit_marker_color") twod_hit_marker:set_colorpicker(color) threed_hit_marker:set_colorpicker(color) delay(0, set_old, old_d2_color, old_d3_color) -- >> restore flags asap end end juju["create_element"]({ ["name"] = "hit marker headshot color" }, { ["colorpicker"] = { ["color_flag"] = "hit_marker_headshot_color", ["default_color"] = Color3.fromRGB(0,255,0), ["transparency_flag"] = "hit_marker_headshot_transparency", ["default_transparency"] = 0 } }) local signal = juju["get_signal"]("on_local_bullet_confirmed") local callbacks = signal["callbacks"] -- >> insert it as the first one so we can set the fflag before the hitmarker runs for i = #callbacks, 1, -1 do callbacks[i + 1] = callbacks[i] end callbacks[1] = hit_callback -- >> clean up juju["on_unload"](function() -- >> remove callback and restore old table positions for i = 1, #callbacks - 1 do callbacks[i] = callbacks[i + 1] end callbacks[#callbacks] = nil end) -- >> loaded juju["create_notification"]("loaded hitmarker head color lua by xander", 1)example script 3:
-- >> variables local juju = juju local create_connection = juju["create_connection"] local is_purchasing = juju["is_purchasing"] local purchase_item = juju["purchase_item"] local players_service = cloneref(game:GetService("Players")) local local_player = players_service["LocalPlayer"] local local_character = local_player["Character"] local local_hrp = local_character and local_character:FindFirstChild("HumanoidRootPart") or nil local on_local_character_loaded = juju["get_signal"]("on_local_character_loaded") local find_first_child = workspace["FindFirstChild"] local wait_for_child = workspace["WaitForChild"] local heartbeat = cloneref(game:GetService("RunService"))["Heartbeat"] -- >> get data local data_folder = wait_for_child(local_player, "DataFolder", 9e9) local information_folder = wait_for_child(data_folder, "Information", 9e9) local muscle_information = wait_for_child(information_folder, "MuscleInformation", 1) or {["Value"] = -150} if not muscle_information then local connection = nil; connection = create_connection(information_folder["ChildAdded"], function(child) if child["Name"] == "MuscleInformation" then muscle_information = child connection:Disconnect() end end) end -- >> ui toggle local toggle = juju["create_element"]({ ["name"] = "auto skinny" }, { ["toggle"] = { flag = "auto_skinny", default = false } }) -- >> core local character_added_connection = nil local auto_skinny_connection = nil local update_character_information = function() local_character = local_player["Character"] local_hrp = wait_for_child(local_character, "HumanoidRootPart", 9e9) end local do_auto_skinny = function() if not local_character or not local_hrp then return end local lettuce = find_first_child(local_player["Backpack"], "[Lettuce]") -- > not setting up caching for an example script f off if lettuce then lettuce["Parent"] = local_character lettuce:Activate() return end if tonumber(muscle_information["Value"]) > -15000 and not is_purchasing() then purchase_item("lettuce") end end create_connection(toggle["on_toggle_change"], function(value) if character_added_connection then character_added_connection:Disconnect() character_added_connection = nil end if auto_skinny_connection then auto_skinny_connection:Disconnect() auto_skinny_connection = nil end if value then character_added_connection = create_connection(on_local_character_loaded, update_character_information) auto_skinny_connection = create_connection(heartbeat, do_auto_skinny) end end) -- >> clean up juju["on_unload"](function() end) Assistant
local juju = juju local create_notification = juju["create_notification"] local function notify_damage(username, displayname, damage) create_notification(displayname .. " has hit you for " .. damage .. " damage!", 2) end local function notify_death(username, displayname) create_notification(displayname .. " has killed you.", 3) end local function on_hit(hit) local attacker = hit.Attacker if attacker and attacker:IsPlayer() then local username = attacker.Name local displayname = attacker.DisplayName local damage = hit.Damage notify_damage(username, displayname, damage) notify_death(username, displayname) end end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(on_hit) end)Explanation:
local juju = juju: This line makes the Juju library available for use.local create_notification = juju["create_notification"]: This gets thecreate_notificationfunction from Juju, which is used to display messages to the player.notify_damage(username, displayname, damage): This function takes the attacker's username, display name, and the amount of damage dealt as input and creates a notification message.notify_death(username, displayname): This function takes the attacker's username and display name and creates a notification message indicating the player has been killed.on_hit(hit): This function is called whenever a player's character is hit by something.- It gets the attacker of the hit.
- It checks if the attacker is a player.
- If the attacker is a player, it gets their username and display name and the damage dealt.
- It then calls
notify_damageandnotify_deathto display the appropriate notifications.
game.Players.PlayerAdded:Connect(function(player)): This connects a function to thePlayerAddedevent, which fires whenever a new player joins the game.player.CharacterAdded:Connect(on_hit): Inside thePlayerAddedfunction, this connects theon_hitfunction to theCharacterAddedevent of the newly joined player. This ensures that whenever the player's character is added to the game, theon_hitfunction will be called for any hits they take.
How to use this script:
- Open your Roblox Studio game.
- In the Explorer window, find the
ServerScriptService. - Right-click on
ServerScriptServiceand select "Insert Object" -> "Script". - Copy and paste the code into the newly created script.
- Run your game.
Now, whenever a player takes damage, they will see a notification saying who hit them and for how much damage. When they are killed, they will see a notification saying who killed them.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.