leader board script:

game.Players.PlayerAdded:connect(function(player) --We create a function that will execute when PlayerAdded fires.
    local leaderstats = Instance.new("Folder") --We create a Model
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player -- We parent the leaderstats object to the player

	local money = Instance.new("IntValue") --We create a new IntValue
	money.Name = "Money" --this is the name you want the leader-stat to be when it shows up in-game.
	money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later)
	money.Parent = leaderstats -- Set the money object as a child of the leaderstats object.
	
	local wantedLevel = Instance.new("IntValue")
	wantedLevel.Name = "Wanted Level"
	wantedLevel.Value = game.Players.LocalPlayer.PlayerGui.wlevel.WLevel
	wantedLevel.Parent = leaderstats
end) --closes function


wanted level script (so far)

wait(0.1)
local WLevel = game.Players.LocalPlayer.PlayerGui.wlevel.WLevel -- testing to see if it works..
local character = game.Players.LocalPlayer.Character
local player = game.Players:GetPlayerFromCharacter(character)
local lvl1 = game.StarterGui.wantedlevel.lv1
local lvl2 = game.StarterGui.wantedlevel.lv2
local lvl3 = game.StarterGui.wantedlevel.lv3
local lvl4 = game.StarterGui.wantedlevel.lv4
local lvl5 = game.StarterGui.wantedlevel.lv5
local randomdist = math.random(110, 175)

if WLevel == 1
    then Instance.new("Cop", workspace)
  lvl1.visible = true
workspace.Cop.Torso.Position = Vector3.new(randomdist,3,randomdist)
    else lvl1.visible = false

end


and a script i am putting in the pedestrians for triggering the cops:

while true do
	local health = Humanoid.Health
	local random = math.random(3)
	if health <= 0 then
		if random == 1 then 
			game.Players.LocalPlayer.PlayerGui.wlevel.WLevel = game.Players.LocalPlayer.PlayerGui.wlevel.WLevel + 1
		end
	end
end

the wanted level doesnt show up on leader board and the variable doesnt change ever

1 comment

0

You have a while true do loop without wait. (last script). this will freeze your game.