01 | local db = true |
02 | script.Parent.Touched:Connect( function (hit) |
03 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
04 | if db = = true then |
05 | db = false |
06 | script.Parent.Transparency = 1 |
07 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
08 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 |
09 | script.Sound:Play() |
10 | script.Parent.Transparency = 1 |
11 | wait( 5 ) |
12 | db = true |
13 | script.Parent.Transparency = 0 |
14 | end |
15 | end |
16 | end ) |
I tested this out myself, and it works. Also, I fixed parts in your script
01 | local db = true |
02 | script.Parent.Touched:Connect( function (hit) |
03 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
04 | if db then |
05 | db = false |
06 | script.Parent.Transparency = 1 |
07 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
08 | if player then |
09 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 |
10 | script.Sound:Play() |
11 | script.Parent.Transparency = 1 |
12 | wait( 5 ) |
13 | script.Parent.Transparency = 0 |
14 | db = true |
15 | end |
16 | end |
17 | end |
18 | 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