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

WantedLevel check script not working?

Ok so the function of this script is to check if someones WantedLevel is 1 or greater then 1 and if it is then it is to change their profession under leaderboard to Criminal. But it does not seem to be working it has no errors in the script and is located under ServerScriptService.

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


function Criminal()
if player.leaderstats.WantedLevel.Value == 1 or player.leaderstats.WantedLevel.Value > 1 then
player.leaderstats.Profession.Value ="Criminal"
end
end


script.Parent.MouseButton1Down:connect(Criminal)

Just figured out I am using a MouseButton1Down script what am I spouse to use?

1 comment

1

Can't use LocalPlayer in server scripts

1 answer

✓ Accepted answer

Well, I told you all you need to know in the chat.

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


function Criminal()
	if player.leaderstats.WantedLevel.Value >= 1 then
		player.leaderstats.Profession.Value ="Criminal"
	end --indents!
end


player.leaderstats.WantedLevel.Changed:connect(Criminal)

Ok well, ServerScriptService does not have a Button1Down event.

You can't use LocalPlayer in server scripts(they work in studio but error in player).

use >= instead of > or ==

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