You killed gui help

I want to make a “you eliminated…” gui.

That pops up when you eliminate someone like “Eliminated…” and their name

Any tips to do this?

1 Like

that is not what he was asking for?

1 Like

you could fire a remote event, also this might help you get on track:

Event.OnClientEvent:Connect(function(VictimName)
	DeathText.Text = VictimName.." has died!"
end)

yeah, but unfortunately im not that good in scripting.

local plrs = game:GetService('Players')

plrs.PlayerAdded:Connect(function(player)
  player.CharacterAdded:Connect(function(c)
    local hum = c:WaitForChild('Humanoid')
    local conn; conn = hum.Died:Connect(function()
     print(('%s died'):format(player.Name))
     conn:Disconnect()
   end)
  end)
end)
2 Likes

can you explain how i use that script?

a gui like this (NOT MY GAME)

https://gyazo.com/68d2807303ce07f7c2566fc1d830a7e9

You can check if target player’s dead after the damage is done to the target player when local player hit them with a sword. If they are dead, you could create (or copy) a gui that says you eliminated them.

This is how you check if the player is dead when the local player hits them.

script.Parent.Handle.Touched:Connect(
    function(Hit)
        if Hit.Parent:FindFirstChildOfClass("Humanoid") and Hit.Parent:FindFirstChildOfClass("Humanoid").Health ~= 0 then --In here, you detect if the touched part's parent has a humanoid class, and if the humanoid is not dead.
            Hit.Parent:FindFirstChildOfClass("Humanoid").Health =
                Hit.Parent:FindFirstChildOfClass("Humanoid").Health - 5 --Decreases health by 5.
            if
                Hit.Parent:FindFirstChildOfClass("Humanoid").Health == 0 or
                    Hit.Parent:FindFirstChildOfClass("Humanoid").Health < 0
             then --Checks if player is dead after the damage is dealt.
                script.Parent.Eliminated:FireClient(LocalPlayer, Hit.Parent.Name) --Fires the elimination gui remote event if the player is dead. The first argument is the local player (Aka the player who killed the target player.), The second argument is the player's name who is dead.
            end
        end
    end
)

And this is the script where you place your gui at local player, showing that you eliminated them.

local Player = game.Players.LocalPlayer
script.Parent.Eliminated.OnClientEvent:Connect(function(TargetPlayersName)
local Gui = --Place the path to your gui
local ClonedGui = Gui:Clone()
ClonedGui.Parent = Player.PlayerGui --Attention! Do NOT parent ClonedGui in StarterGui. It will not work.
ClonedGui.Text.Text = "You Eliminated "..TargetPlayersName.."." --Set the text that it says you eliminated the target player.
wait(3)
ClonedGui:Destroy()
end)

This is pretty much all! Have a great day! :heart:

2 Likes

thank you, but where should place the scripts?

So there is Local Scripts and Server Scripts. Everything a user does on their own system, for example a key press or movement of the mouse should all be placed in a Local Script. A Server Script can handle everything on the server, but can of course not register user input because it runs on the server, not the client. So you place the top script in a (Server) Script, and the bottom script will go in StarterPlayer > StarterPlayerScripts.

Hey. The first one should be on the tool. I also forgot to add some stuff to add.
You could use .Equipped for it to work, and you also need to define the LocalPlayer at the remote event firement. You also need to create a remote event name Equipped so script can fire it.

Sorry if i ask many questions. But how do i use .Equipped? And how do i define the LocalPlayer at the remote?

Thank you.

.Equipped is an event fires when player equips a Tool | Roblox Creator Documentation. It basically runs the code you write inside it when player equips a tool.

Now, how can you define the local player?

When you equip a tool, The Tool is moved from Backpack to Player’s Character. And when you unequip it, it moves from Player’s Character to Backpack.

local Tool = --Define where the tool is.
Tool.Equipped:Connect(function()
local Character = Tool.Parent
end)

Since when you equip your tool, and your tool parents as Player’s Character, you can get the Player’s Character by doing Tool.Parent to it.

Now, you got the character. But how will you get the Player and not Character?

There is GetPlayerFromCharacter()!

With this function, you can get the Player object with Player’s Character!

local Tool = --Define where the tool is.
Tool.Equipped:Connect(function()
local Character = Tool.Parent
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
end)

And now you have the player object!
Now you can fire the remote event by giving the player’s name.

im sorry but how do i put all this into the scripts now? im new to scripting so im not that good.

--Server script
local Tool = --Define where the tool is.
Tool.Equipped:Connect(function()
local Character = Tool.Parent
local LocalPlayer = game:GetService("Players"):GetPlayerFromCharacter(Character)
script.Parent.Handle.Touched:Connect(
    function(Hit)
        if Hit.Parent:FindFirstChildOfClass("Humanoid") and Hit.Parent:FindFirstChildOfClass("Humanoid").Health ~= 0 then --In here, you detect if the touched part's parent has a humanoid class, and if the humanoid is not dead.
            Hit.Parent:FindFirstChildOfClass("Humanoid").Health =
                Hit.Parent:FindFirstChildOfClass("Humanoid").Health - 5 --Decreases health by 5.
            if
                Hit.Parent:FindFirstChildOfClass("Humanoid").Health == 0 or
                    Hit.Parent:FindFirstChildOfClass("Humanoid").Health < 0
             then --Checks if player is dead after the damage is dealt.
                script.Parent.Eliminated:FireClient(LocalPlayer, Hit.Parent.Name) --Fires the elimination gui remote event if the player is dead. The first argument is the local player (Aka the player who killed the target player.), The second argument is the player's name who is dead.
            end
        end
    end
)

end)

--Local Script
local Player = game.Players.LocalPlayer
script.Parent.Eliminated.OnClientEvent:Connect(function(TargetPlayersName)
local Gui = --Place the path to your gui
local ClonedGui = Gui:Clone()
ClonedGui.Parent = Player.PlayerGui --Attention! Do NOT parent ClonedGui in StarterGui. It will not work.
ClonedGui.Text.Text = "You Eliminated "..TargetPlayersName.."." --Set the text that it says you eliminated the target player.
wait(3)
ClonedGui:Destroy()
end)

Make sure Remote Event, Server script and Local script is located directly inside the tool. And make sure your tool has a handle.

https://gyazo.com/d794e8f2275f39175266133e99088c44

i get this error.

In the second line of the local script, eleminated was called, there is no such thing as eleminated mentioned in the script. Perhaps change it to Player instead? (I’m not sure, but just guessing)

@MiniYear can you help me with the error? Thank you

The code you’re being given isn’t going to just magically work with your scripts. You need to make an effort to actually incorporate it.

If you still have issues, post your damage script code.

1 Like

how can my damage script matter on a gui?