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

How do i fix my clickdetector for gui script that wont work?

Asked by 5 years ago

im using clickdetector inside brick, it has a normal script inside:

script.Parent.ClickDetector.MouseClick:Connect(function(p)
    if p.Character.Masked.Value == true then
        if p.Character.Bag.Value == false then
        print("Stolen")
        --give bag to character
        p.Character.Bag.Value = true
        script.Parent.Parent:Destroy()
        elseif p.Character.Bag.Value == true then
        p.PlayerGui.bagwarning.Enabled = true
        wait(1)
        p.PlayerGui.bagwarning.Enabled = false
        end
    end
end)

i also tried

script.Parent.ClickDetector.MouseClick:Connect(function(p)
    if p.Character.Masked.Value == true then
        if p.Character.Bag.Value == false then
        print("Stolen")
        --give bag to character
        p.Character.Bag.Value = true
        script.Parent.Parent:Destroy()
        elseif p.Character.Bag.Value == true then
        p.PlayerGui["bagwarning"].Enabled = true
        wait(1)
        p.PlayerGui["bagwarning"].Enabled = false
        end
    end
end)

and supposedly the (p) is the player that clicks it which is me, and i even CHECKED for that screen gui, the name IS correct, but it doesnt work and output says:

bagwarning is not a valid member of PlayerGui

please help :()

0
simple, is bagwarning actually a valid member of PlayerGui? check it manually starmaq 1290 — 5y
0
THATS EXACTLY WHAT I SAID, I CHECKED AND ITS THERE! CommanderCaubunsia 126 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

From what I know, a normal script can't access the playergui due to filtering enabled. You would have to use a remote event, from the server to the client, to disable/enable the GUI. https://developer.roblox.com/articles/Remote-Functions-and-Events

Or, you could also simply change the script to a local script. That should fix it, unless there is an error elsewhere.

Ad

Answer this question