Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a GUI show when a block is touched? [Un-Answered!]

Asked by 10 years ago

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)
0
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. Aethex 256 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago
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.

Ad
Log in to vote
-1
Answered by 10 years ago

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)
0
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. SquirreIOnToast 309 — 10y
0
2) I fixed the Touched event. 3) You didn't reset debounce to true so this function is non-reusable. SquirreIOnToast 309 — 10y
0
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). fahmisack123 385 — 10y
0
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. GoldenPhysics 474 — 10y
0
Thanks for telling me, I didn't know that. fahmisack123 385 — 10y

Answer this question