How would I check if a players leaderstat value is more than ten, and if it is, remove ten from their leaderstat?

When a player interacts with this ProximityPrompt, I want it to check if the player has more than 10 “Friends”, (the leaderstat), and if they do, then I’d like their leaderstat value to go down by 10, and do some extra stuff which already works.
There is no error message in the output, but nothing happens when I interact with the proximityprompt.
I looked around and revised a bit, but nothing really, here is my script so far:

workspace.NoobStuff.NoobProxPrompt1.ProximityPrompt.Triggered:Connect(function(bought)
	
	local friends = bought:WaitForChild("leaderstats").Friends
	if friends.Value >= 10 then
	workspace.NoobStuff.NoobBought1.Transparency = 0
	workspace.NoobStuff.NoobProxPrompt2.ProximityPrompt.Enabled = true
		workspace.NoobStuff.NoobProxPrompt1.ProximityPrompt.Enabled = false
		friends.Value =-10
	end
end)

Any help would be appreciated as I am not very experienced with scripting. Thanks

just change

friends.Value =-10

to

friends.Value -=10

also you might want to change the if statement to
if friends.Value > 10 then
(just if your ok with them having 10 friends)

1 Like

I tried it, but still nothing happened, no error or anything either

Sorry for necroposting but since you haven’t found a solution:

=- and -= doesn’t work

You need to do:

friends.Value = friends.Value - 10

friends.Value -= 10 is the same as friends.Value = friends.Value - 10

Are you using a Script or a LocalScript? And where is the script parented?

workspace.NoobStuff.NoobProxPrompt1.ProximityPrompt.Triggered:Connect(function(bought)
	
	local friends = bought:WaitForChild("leaderstats").Friends
	if friends.Value >= 10 then
	workspace.NoobStuff.NoobBought1.Transparency = 0
	workspace.NoobStuff.NoobProxPrompt2.ProximityPrompt.Enabled = true
		workspace.NoobStuff.NoobProxPrompt1.ProximityPrompt.Enabled = false
		friends.Value -= 10
	end
end)

That doesn’t work in Roblox Lua

Edit: sorry just realized it was added