I was trying to make a collectable ring, everything was working. Once I collect the ring, it turns invisible. However the ring is not turning opaque again even though I have wrote the script to turn it's transparency to 0.
There are no errors in the output either
Here is the code:
01 | local db = true |
02 | script.Parent.Touched:Connect( function (hit) -- The player hits the part |
03 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then -- Just to check if its not nil |
04 | if db = = true then -- Just to check if the db is true |
05 | db = false |
06 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Getting the player |
07 | player.leaderstats.Rings.Value = player.leaderstats.Rings.Value + 1 -- Giving Currency |
08 | script.Parent.Transparency = 1 -- Making it invisible |
09 | script.Parent.CanCollide = false -- Now the player can walk through the ring |
10 | script.Parent.Bubble:Play() -- Playing the sound |
11 | wait( 2 ) |
12 | -- Respawning the ring: |
13 | db = true |
14 | script.Parent.Transparency = 0 |
15 | script.Parent.CanCollide = true |
16 | end |
17 | end |
18 | end ) |
Anything I can do?
01 | script.Parent.Touched:Connect( function (hit) |
02 | local player = hit.Parent:FindFirstChild( "Humanoid" ) |
03 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
04 | if plr.leaderstats.Coins.Value > = 0 then |
05 | wait() |
06 | script.Disabled = true |
07 | script.Parent.Transparency = 1 |
08 | script.Parent.CanCollide = false |
09 | plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1 |
10 | wait( 1 ) |
11 | script.Parent.Transparency = 0 |
12 | script.Parent.CanCollide = true |
13 | script.Disabled = false |
14 | end |
15 | end ) |
The script works fine for me, It's either 1: Your sound is probably misspelled or something. 2: You do not have leader stats or the leader stats is misspelled again.