Making a thing where money drops when player dies. Problem is that the cash can be picked up by dead players. Is there a way to fix that, or even add a small cooldown when it spawns so it can't be instantly collected?
local DONTTOUCH = true local Cash = script.Parent local function PlayerTouched(player) if DONTTOUCH == true then DONTTOUCH = false local humanoid = player.Parent:FindFirstChild('Humanoid') local player = game.Players:FindFirstChild(player.Parent.Name) if humanoid and player then player.leaderstats:WaitForChild("Cash").Value += 5 Cash.Transparency = 1 Cash["Pickup"..math.random(1,3)]:Play() wait(1) Cash:Destroy() end end end Cash.Touched:Connect(PlayerTouched)
I’m currently on my phone but this should be the correct answer, if not let me know!
local DONTTOUCH = true local Cash = script.Parent local function PlayerTouched(playerPart) if playerPart.Parent:FindFirstChild("Humanoid") then local playerChar = playerPart.Parent local player = game.Players:GetPlayerFromCharacter(playerChar) if playerChar.Humanoid.Health >= 0 then if DONTTOUCH == true then DONTTOUCH = false player.leaderstats:WaitForChild("Cash").Value += 5 Cash.Transparency = 1 Cash["Pickup"..math.random(1,3)]:Play() wait(1) Cash:Destroy() end end end end Cash.Touched:Connect(PlayerTouched)
That should be the fix if not let me know and I’ll hop on the computer and fix it up properly. I might’ve misspelled some things since I’m on ios and if I did I apologize. I’ll be sending you a friends req. My main account is named M9F.