Is there an way to increase points with ProximityPrompt?

Is there any way to make an ProximitiyPrompt give points?
I saw an way here but it didn’t work.

That is the one i tried.

local ProximityPrompt = script.Parent

ProximityPrompt.Triggered:connect(function(Player)

Player.leaderstats.Gold.Value += 1

end)

Leaderboard script:
local Players = game:GetService(“Players”)

–Function–
local function leaderboardsetup(player)
** local leaderstats = Instance.new(“Folder”)**
** leaderstats.Name = “leaderstats”**
** leaderstats.Parent = player**



** local gold = Instance.new(“IntValue”)**
** gold.Name = “Pizzas”**
** gold.Value = 0**
** gold.Parent = leaderstats**



end

Players.PlayerAdded:Connect(leaderboardsetup)

Hey! I would like to help but its really hard to read your code when its not formatted.

When posting code use the button that looks like code (above the text when typing a response), then paste your code.

1 Like

i just fixed it
image
I needed to add ProximityPrompt to the end of the script.

Even though I finished it and it works, I tried adding sound to it, but…
uh…

local sound = script.Sound

soundID = "rbxassetid://665786174"

local ProximityPrompt = script.Parent.ProximityPrompt

game.Workspace.ProximityPrompt.Triggered:Connect(function(player)

player.leaderstats.Pizzas.Value += 1

sound:Play()

end)

Instead of

soundID = "rbxassetid://66578617"

Do

sound.soundID = "rbxassetid://66578617"

This will not work, since soundID is not a property of Sound. Instead, the script should be:

local ProximityPrompt = workspace.ProximityPrompt

local sound = script:WaitForChild("Sound")
local soundID = "rbxassetid://665786174"
sound.SoundId = soundID

ProximityPrompt.Triggered:Connect(function(player)
	player.leaderstats.Pizzas.Value += 1
	
	sound:Play()
end)
2 Likes

It doesnt work, it doesnt give points or play the “Pizza Time” Sound… (also i changed the id afterwards) edit: and after i copy and pasted it and nothing happened still

I made it based on your script, if something doesn’t work then it’s because you did something wrong, check the output to see if it gives any errors. Btw if you need support for other things you should create a new topic.

Can you send your code now, a screenshot of the output (if there are any errors), and a screenshot of the explorer where the script and sound are?

Im pretty sure that means that there is not sound that has the parent of the script.