✓ Accepted answer
debounce = false
script.Parent.Touched:Connect(function(hit)
if debounce == false then
debounce = true
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local frame = player.PlayerGui.shaking.Frame
frame.Visible = true
wait(5)
frame.Visible = false
end
end
end)
Okay, you had some more errors in there that I corrected.
You have to check if the debounce is false so that it knows to continue, and then set it to true after you check if it's false.
You then need to check if whatever hit it has a humanoid, so that the code doesn't error if a random part touches it.
You then need to get the character's player, and set that to a variable(in this case the variable is called player)
You also need to change StarterGui to PlayerGui, since starterGui only clones its children when the player joins.
Lastly, you don't need the last debounce since it changes after it checks it, therefor not allowing it to run through the code again.
Hopefully this helped, and if it did please accept the answer! :D
4 comments
Well, the error here is indexing the frame in startergui. You need to make changes to gui in a player's PlayerGui
You'd have to get the player from the character which I don't know how to do but there should be tutorials.
player = game.Players:GetPlayerFromCharacter(hit.Parent) is how you want to go about doing that
And then just get the frame from playergui, could you construct that into an answer?