Still have questions? Join our Discord server and get real time help.
0

# The Coin is not respawning after 5 seconds?

Edited 1 year ago
local db = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
script.Parent.Transparency = 1
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
script.Sound:Play()
script.Parent.Transparency = 1
wait(5)
db = true
script.Parent.Transparency = 0
end
end
end)


0
1 year ago

I tested this out myself, and it works. Also, I fixed parts in your script

local db = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db then
db = false
script.Parent.Transparency = 1
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
script.Sound:Play()
script.Parent.Transparency = 1
wait(5)
script.Parent.Transparency = 0
db = true
end
end
end
end)


seemed like the rest of the script was running even though it didn't check to see if it was an actual player, and maybe make this a server script, and check to see if the script isn't disabled