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

Why does the player not kick when the numbervalue changes?

Asked by 4 years ago

So i'm making a script for when the number in the numberValue changes, the player gets kicked. Why does this not work?(Yes, i'm using a localscript)

local plr = game.Players.LocalPlayer
if script.NumberValue.Changed then
    plr:Kick('noob')
end

1 answer

Log in to vote
1
Answered by
zane21225 243 Moderation Voter
4 years ago

You solved your own problem. You can't use the :Kick() instance via a LocalScript, rather a Script.

Also, you can't properly run script.NumberValue.Changed.

See code below:

local kickreason = 'numbervalue changed'

game.Players.PlayerAdded:Connect(function(player)
    script.NumberValue:GetPropertyChangedSignal('Value'):Connect(function()
        player:Kick(kickreason)
    end)
end)
0
Also, if the number value is changed from the server, the change does not replicate to client. This is particular to value objects. It has to get the change from the same part it is made. Necro_las 412 — 4y
Ad

Answer this question