✓ Accepted answer
This can be done with a server script but is pointless as it would just waste server processing when this task can be done locally without the server.
We will need:-
The local players gui
A reference to the part to connect the event
The gui that we want to show (also check for duplicated)
The list above is just a basic example you can add more checks in if needed
This is an example only, there are better solutions:-
local part =
local txtGui =
local plrGui = game.Players.LocalPlayer:WaitForChild('PlayerGui')
local plrName = game.Players.LocalPlayer.Name
local deb = false
part.Touched:connect(function(hit)
if deb then return end
if hit.Parent.Name == plrName then
deb = true
if not plrGui:FindFirstChild('textGui') then
txtGui:Clone().Parent = plrGui
end
wait(2)
deb = false
end
end
I have not added a check to see if the player is still alive e.g health > 0. This can be easily added in.
Hope this helps, please comment if you do not understand how / why this code would work.
Useful Links
StarterGui and PlayerGui; Not the Same
Debounce
LocalPlayer
ReplicatedStorage
2 comments
Because of the format in your code block can you tell me if I put all of this in one script or if you are just telling me these to use in my own scripts.
it is all one script but you will need to add to it to make it work e.g. the parts location.