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

Is there a way to make it so only premium players can have shift lock?

I tried this but it does not work

local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player) if player.MembershipType == Enum.MembershipType.Premium then player.CharacterAdded:connect(function(char) local humanoid = char:findFirstChild("Humanoid") if humanoid then humanoid.MaxHealth = 200 humanoid.Health = 200 game.StarterPlayer.EnableMouseLockOption = true end end) end end)

I also gave premium players 200 health but I don't know if this affects the resto fo the script.

1 answer

✓ Accepted answer

Try using the following in a LocalScript (make sure to put it in a place that LocalScripts can run, for example in StarterPack):

local player = game:GetService("Players").LocalPlayer

--If they don't have Premium, disable shift lock
if player.MembershipType ~= Enum.MembershipType.Premium then
	player.DevEnableMouseLock = false
end

I would try to help give an explanation as to why the code you provided didn't work, but it is very difficult to read due to the lack of indentation and codeblock. If you could correct that it would help immensely in solving your problem.

Hope this helps.

Edit: Just realized, if you're going to change the player's MaxHealth as well, use the following code instead:

local player = game:GetService("Players").LocalPlayer

--If they have Premium, give them more health. If they don't, disable shift lock.
if player.MembershipType == Enum.MembershipType.Premium then
    player.Character.Humanoid.MaxHealth = 200
else
	player.DevEnableMouseLock = false
end

1 comment

0

Ok thanks. Also I don't know how to paste the code like how you did. I copied and pasted it in ti the question box but it would not let me indent.

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