Leaderstats is not a valid member of RBXScriptSignal

I’m trying to do a ProximityPrompt that gives you money when triggered.

Error:
10:49:07.116 leaderstats is not a valid member of RBXScriptSignal - Server - Script:4
10:49:07.116 Stack Begin - Studio
10:49:07.116 Script ‘Workspace.Money.ProximityPrompt.Script’, Line 4 - Studio - Script:4

Script:

local money = script.Parent.Parent
local plr = game.Players.PlayerAdded or game:GetService(“Players”).LocalPlayer
local leaderstats = plr.leaderstats.Money

money.ProximityPrompt.Triggered:Connect(function(player)
leaderstats.Value = leaderstats.Value+(math.random(50,300))
money:Destroy()
end)

does the money model have a ProximityPrompt?

Yes it does

image

local model = script.Parent.Parent

script.Parent.Triggered:Connect(function(plr)
plr:WaitForChild("leaderstats").Money.Value += (math.random(50,300))
model:Destroy()
end)

Try this instead?

1 Like

I tried WaitForChild too
image

i edited the script just now try that

local money = script.Parent.Parent

money.ProximityPrompt.Triggered:Connect(function(player)
player.leaderstats.Money.Value +=(math.random(50,300))
money:Destroy()
end)

try this

1 Like

I still wonder why’d you use LocalPlayer when it should only be on client. Change that to this if you’re expecting only the player to return.

game.Players.PlayerAdded:Wait()
1 Like