Hi.
I am trying to make a coin in studio, but every time I die inside of the game, then respawn, the coin stops working?
I want to wonder why this is happening, I fixed some mistakes in the scripts but it looks like those mistakes weren’t the problem on why the coin wouldn’t work when you respawned back into the game.
Help please?
Here is a video that explains everything of what I am talking about:
robloxapp-20221109-1247219.wmv (2.7 MB)
Here is the script for the coin collecting:
local plr = game.Players.LocalPlayer
local coins = plr:WaitForChild('Value')
local chr = plr.Character or plr.CharacterAdded:Wait()
local hum = chr:WaitForChild('Humanoid')
local cooldown = 5
hum.Touched:Connect(function(part)
if part:IsA('MeshPart') and part.Name == 'Coin' then
part.Name = 'CoinCollected'
part.Transparency = 1
game.Workspace["Coin grab"]:Play()
coins.Value += 1
wait(cooldown)
wait(1)
part.Transparency = 0
part.Name = 'Coin'
-- Repeat process again after this line --
end
end)
Thank you.