Mouse not changing

Uh I have no clue what I did wrong, nothing in the output.

script:

local mouse = localPlayer:GetMouse()
if localPlayer.leaderstats.Stage == 1 then
	mouse.Icon = "rbxassetid://591085866"
else
	mouse.Icon = ""
end
1 Like

add a print() into the if statement to see if itll print anything

local mouse = localPlayer:GetMouse()
if localPlayer.leaderstats.Stage == 1 then
	mouse.Icon = "rbxassetid://591085866"
    print("test testing test yes test")
else
	mouse.Icon = ""
end

I changed the script to this

local mouse = localPlayer:GetMouse()

print("this ran")
if localPlayer.leaderstats.Stage == 1 then
	mouse.Icon = "rbxassetid://591085866"
	print("test testing test yes test")
else
	mouse.Icon = ""
	print("no did not work")
end

none of them printed.

leaderstats is not a valid member of Player "Players.Furkan5E"
local mouse = localPlayer:GetMouse()
if localPlayer:WaitForChild("leaderstats").Stage.Value == 1 then
	mouse.Icon = "rbxassetid://591085866"
else
	mouse.Icon = ""
end

Try this.

1 Like

Is leaderstats.Stage a value? If so try leaderstats.Stage.Value.

1 Like

the error is to do with leader stats, but I think you are right, I will make this change.

I tried this, and I put prints in none of them are printing, the script is not running for some reason, no errors

That’s cause waitforchild i think is yielding for something that is nil or unexisting. Because the error says leaderstats doesn’t exist.

1 Like

now the script is not running at all.

Is leaderstats there? Where is it being created at?

in server script service

game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local stage = Instance.new("StringValue")
	stage.Name = "Stage"
	stage.Value = stageData or "1"
	stage.Parent = leaderstats
end)

I see , use

             if localplayer:WaitForChild("leaderstats").Stage.Value == "1" then 

because stringvalue.

I think we are looking for leaderstats in the wrong place becauseleaderstats is in players

or this is completely wrong.

Yes and localplayer gets the client which is in players.

then why is it not working???

Show me your current code so I can debug.

local mouse = localPlayer:GetMouse()
if localPlayer:WaitForChild("leaderstats").Stage.Value == 1 then
	mouse.Icon = "rbxassetid://591085866"
else
	mouse.Icon = ""
end

Try instead of 1 use “1” because stringvalue.

Maybe try doing this

local mouse = localPlayer:GetMouse()

local leaderstats = localPlayer:WaitForChild('leaderstats')
local stage = leaderstats.Stage

stage:GetPropertyChangedSignal('Value'):Connect(function()
   if stage.Value == '1' then
	   mouse.Icon = "rbxassetid://591085866"
   else
	   mouse.Icon = ""
   end
end)