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

Why Isn't my leaderstats script cooperating?

I am making a tycoon, and I have a script to make a wall appear when the player has a certain amount of money, but There keeps being a red line under the minus symbol. Heres the script:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player.leaderstats.Cash.Value >= 1000 then
			game.Workspace.wall.CanCollide = true
			game.Workspace.wall.Transparency = 0
			player.leaderstats.Cash.Value - 1000   -- Here is the error. The minus is squiggled.
		end
	end
end)

1 answer

✓ Accepted answer

You need to change it to

player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 1000

You need to subtract it this way otherwise it would not work.

2 comments

0

Oh yeah im stupid

0

np, we all make mistakes.

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