I have been trying to make a simple function using a ProximityPrompt and a part that reduces an in game leaderstats currency and have the recurring issue of the function title “player” not being considered a player in game.Players. Any help would be much appreciated.
I think you should check if the player exists first, then run the rest of the code.
Try and see if this code works:
script.Parent.ProximityPrompt.Triggered:Connect(function(player)
if player then
player:WaitForChild("leaderstats").smackDollars.Value -= 100
player:WaitForChild("Backpack").Shmack:Destroy()
game.Workspace.Shmack2.Parent = player.Backpack
script.Parent.ProximityPrompt:Destroy()
end
end)