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

Why won't this GUI button work?

Asked by
JJ_B 250 Moderation Voter
8 years ago

Expanding on my PM script, I made a button in a ScreenGUI that changes whether a person can received PMs or not. However, when the button is clicked, the value does not change and neither does the text. The output tells me nothing. Here is the script:

while true do
    if game.Players.LocalPlayer:FindFirstChild("PM") == nil then
        f = Instance.new("BoolValue")
        f.Name = "PM"
        f.Value = true      
        f.Parent = game.Players.LocalPlayer
    end
    wait(0.2)
end

script.Parent.MouseButton1Down:connect(function()
    print ("hi")
    if script.Parent.on.Value == false then
        script.Parent.on.Value = true
        game.Players.LocalPlayer.PM.Value = true
        script.Parent.Text = "PMs Allowed"
    elseif script.Parent.on.Value == true then
        script.Parent.on.Value = false
        game.Players.LocalPlayer.PM.Value = false
        script.Parent.Text = "PMs Disallowed"
    end
end)

Can anyone help? The print doesn't show in the output either.

1
The function will never execute because the while true do loop will continue forever. You'll need to put the function into another script inside the button. I think this is the problem anyway. MasterDaniel 320 — 8y
0
Thanks. I used PlayerAdded instead. Thanks for the help. JJ_B 250 — 8y
0
Click the Answered button on the right, :l I was ready to answer but you've already got the help. Codebot 85 — 8y

Answer this question