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.

3 comments

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.

0

Thanks. I used PlayerAdded instead. Thanks for the help.

0

Click the Answered button on the right, :l I was ready to answer but you've already got the help.