Hello developers,
I am trying to make when proximity prompt triggered the parent of proximity prompt(NPC) destroy and player money will increase. But there is a problem that I don’t know how to solve. The script did not run at all furthermore there was no error in the output. It will be a great help if anyone could help me solve this problem.this is my code:
local charclone = game.Workspace.CharacterClone
for I , v in pairs(charclone:GetChildren())do
v.HumanoidRootPart.ProximityPrompt.Triggered:Connect(function(player)
v:Destroy()
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 15
game.ReplicatedStorage.Remotes.IceCreamJobEvent:FireClient(player)
print("beep boop")
end)
end
why are you putting an event in a for loop? It would probably be better to do this
local charclone = workspace.CharacterClone
charclone.HumanoidRootPart.ProximityPrompt.Triggered:Connect(function(player)
for I , v in pairs(charclone:GetChildren())do
v:Destroy()
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 15
game.ReplicatedStorage.Remotes.IceCreamJobEvent:FireClient(player)
print("beep boop")
end)
end