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

Why is my shift lock disable script not disabling shift lock?

Asked by 5 years ago

So basically I created a script so if a player is a certain rank or lower in the group they can't use Shift Lock. I tested it with making it so it equals 255 which is my rank but it' still not working. I can still change my shift lock. Why?

game.Players.PlayerAdded:Connect(function(player)
    if player:GetRankInGroup(4525647) <= 1 then
        game.Players:WaitForChild(player).EnabledMouseLockOption = false
    end
end)

1 answer

Log in to vote
0
Answered by 5 years ago

Firstly, no need to wait for the player when they already exist. PlayerAdded fired when they join the game so it makes no sense to wait for the player. Secondly, the property is called DevEnableMouseLock.

game.Players.PlayerAdded:Connect(function(player)
    if player:GetRankInGroup(4525647) <= 1 then
        player.DevEnableMouseLock = false
    end
end)

Finally, you can omit the if statement and just set the property to the opposite of the result of player:GetRankInGroup(4525647) <= 1.

game.Players.PlayerAdded:Connect(function(player)
    player.DevEnableMouseLock = player:GetRankInGroup(4525647) > 1
end)

But you can keep the if statement if you wish.

Ad

Answer this question