When ProximityPrompt.Triggered

Hey Devs! I’m making a prompt when is triggered it gives you +5 gold. If this is obvious to make, sorry, I’m a beginner scripter. Everything is in local scripts.

  1. What do you want to achieve? When proximityprompt.Triggered I need to add 5 gold to the player. (leaderboard value)

  2. What is the issue? I tried using many ways and scripts and I didn’t think I would have problems with a simple thing like that. It doesn’t work

  3. What solutions have you tried so far? Searched the internet and tried making many scripts.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- I put it in ProximityPrompt for now. I used StarterPlayerScripts and Server Script Service too.
-- this is my last script I have for it so it may be bad.
local playerModel = script.Parent
local player = game.Players:GetPlayerFromCharacter(playerModel)
game.ReplicatedStorage:WaitForChild("leaderstats")
player.leaderstats:WaitForChild("IntValue")
workspace.WorkButton.ProximityPrompt.Triggered:Connect(function(player)
	local gold = player.leaderstats.IntValue
	if player then 
		gold.Value = gold.Value + 5
	end
end)

Thanks for all the answers!

I don’t understand what’s going on there, none of that code looks needed and is probably erroring when trying to get the leaderstats from that, you just need the Triggered stuff

workspace.WorkButton.ProximityPrompt.Triggered:Connect(function(player)
	local gold = player.leaderstats.IntValue
	if player then 
		gold.Value += 5
	end
end)
1 Like

Oh, my brain doesn’t like to work :grinning:
Thanks, Embat for helping others and especially me. I really appreciate it.

1 Like

Glad to be of help to you and others! If you have anymore issues don’t be afraid to make another post!

1 Like