I made a parcour and i want that when a player touched the end brick. he teleports back and add 5 money. now i have this, But when i now stand on the end brick i get 5, 10, 15 or 20 money.
this is the scripts.
script.Parent.Touched:Connect(function(hit)
local hum = hit.Parent:findFirstChild("Humanoid")
if hum ~= nil then
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(17,10,-61)
for i,player in ipairs(game.Players:GetPlayers()) do
if player.Character then
local stat = player:FindFirstChild("leaderstats")
if stat then
player.leaderstats.Money.Value = player.leaderstats.Money.Value +5
end
end
end
end
end)
Can you please help me. Thank you

3 comments
Does it print any errors?
Where it says CFrame.new(17,10,-61), you need to change it to CFrame.new(Vector3.new(17, 10, -61))
I had a question similar to this! Sadly, none of the answers I got worked. check out my question, the link is: https://scriptinghelpers.org/questions/84971/how-to-loop-through-each-player-and-add-currency-if-they-destroy-a-building