Checking player leaderstat value, and removing ten

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)

I want the script to check if a player has 10 or more “friends”, which is the leaderstat, and if they do, remove 10 from the player’s “friends”, and some extra things that already work.

There is no error in the output, but nothing happens. I’ve guessed that it has something to do with line three and that I am just putting the wrong area to find the leaderstat.

I have looked on the dev hub but only found things for other problems, and I tried to change line 3 a bit, but nothing.
Any help would be appreciated.

Hi there,

Is this a server Script or a LocalScript? Where exactly is it located?

It is a server script located in the same part as the proximityprompt the script checks for

Is NoobBought1 a model or part?

NoobBought1 is a part

eeeeeeeee

workspace.NoobStuff.NoobProxPrompt1.ProximityPrompt.Triggered:Connect(function(bought)
	
	local friends = bought:WaitForChild("leaderstats"):WaitForChild("Friends")
	if friends.Value > 9 then
		workspace.NoobStuff.NoobBought1.Transparency = 0
		--i didn't read the script well...
		workspace.NoobStuff.NoobProxPrompt2.ProximityPrompt.Enabled = true
		workspace.NoobStuff.NoobProxPrompt1.ProximityPrompt.Enabled = false
		
		friends.Value -= 10
	end
end
1 Like

Try this :slightly_smiling_face:

workspace.NoobStuff.NoobProxPrompt1.ProximityPrompt.Triggered:Connect(function(player)
    local friends = player.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)

1 Like

Both of these scripts work thank you but I will give the solution to @lV0rd because he gave a script first

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.