Exactly what the title says, here's what I tried:
script.Parent (function(hit)
game.StarterGui.ScreenGui.GoodJob.Visible = true
wait(10)
game.StarterGui.ScreenGui.GoodJob.Visible = false
end)
Exactly what the title says, here's what I tried:
script.Parent (function(hit)
game.StarterGui.ScreenGui.GoodJob.Visible = true
wait(10)
game.StarterGui.ScreenGui.GoodJob.Visible = false
end)
local debounce = true
script.Parent.Touched:connect(function (hit) --You missed "connect"
if not hit.Parent:FindFirstChild("Humanoid") then return end --Check to see if it's a player.
if not debounce then return end
debounce = false --Debounce prevents the function being called multiple times.
game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.ScreenGui.GoodJob.Visible = true --PlayerGui must be edited, NOT ScreenGui. ScreenGui isn't the live GUI.
wait(10)
game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.ScreenGui.GoodJob.Visible = false
debounce = true
end)
I'm Aurum, and you're welcome.
The guy above forgot something...
Lemme get this right, if a someone touches a brick, then a GUI pops up?? If so, then copy this:
--PUT THIS IN A LOCALSCRIPT Inside the brick inside the player
brick = game.Workspace. --Complete the path to the brick
Gui = game.Players.LocalPlayer.PlayerGui --Complete the path to the Gui.
time = 10 --Waits 10 seconds before being allowed to be touched again. You can change this.
debounce = true --Leave this alone
script.Parent.Touched:connect(function(hit) --Aurum forgot the Touched event...
if debounce == true then
debounce = false
if hit.Parent.Name == game.Players.LocalPlayer.Name then
Gui.Visible = true
end --Ends the second if
end --Ends the first if
wait(time)
debounce = true
end)
Why your script is wrong: 1) This is from a server script, as referenced at line 1, script.Parent. Your script at line 3 contains LocalPlayer, which is a LocalScript variable.
Thanks for the debounce indication, BUT, I even stated, in line 1 to put it in a LocalScript. You should use LocalScripts to avoid any lag in servers, and also use them in Gui's (Recommended).
You would have to set brick equal to game.Worspace, etc. and put that script within the player. Local Scripts in workspace don't execute any code.
Thanks for telling me, I didn't know that.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
http://wiki.roblox.com/index.php?title=Touched Also, you don't want to edit the StarterGui, you need to edit the player's PlayerGui.