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

WantedLevel check script not working?

Asked by 8 years ago

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
Can't use LocalPlayer in server scripts theCJarmy7 1293 — 8y

1 answer

Log in to vote
0
Answered by
theCJarmy7 1293 Moderation Voter
8 years ago

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 ==

Ad

Answer this question