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

No errors popping up once I execute script..?

Asked by 4 years ago

So I am making a script that will make a text pop up if you click on a brick. It doesn't work though, and there are no errors that popped up.

script.Parent.ClickDetector.MouseClick:Connect(function(onClick)
end)
        game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = true

    wait (5) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = false
0
The code needs to be within the function scope Ziffixture 6913 — 4y

2 answers

Log in to vote
0
Answered by
JPT79 92
4 years ago

You didn't write the code inside of the function

script.Parent.ClickDetector.MouseClick:Connect(function(onClick)
    --This is where you should put the function's code

end) --This is the end of the function
    --This is outside of the function so it won't fire when the function is called upon
        game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = true

    wait (5) game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = false

So if you just placed your code inside the function like this

script.Parent.ClickDetector.MouseClick:Connect(function(onClick)
        game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = true
     wait(5)
    game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = false
end)

Everything should work as intended

Ad
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

Try this script:

local Part = script.Parent

script.Parent.ClickDetector.MouseClick:Connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then 
        local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
        game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = true
        wait (5) 
        game.Players.LocalPlayer.PlayerGui.DoorBGui.Locked.Visible = false
    end
end)
0
that doesnt work Andrey_Diamonds 4 — 4y

Answer this question