Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.