Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

My fence transparency not work correctly, why?

Asked by 1 year ago
Edited 1 year ago

I would like that when there are more than 3 zombies in the game the barrier becomes transparent and when there are less than 3 it comes back to 0.8 transparency but my script not work and I dont understand why. Can you help me please?

Sorry I dont speak english i'm Qu├ębecker and I have 16 years old so I don't perfectly speak in english:/

"/900" because the "i" return +10100 value


while wait() do local ZombiesInGame = workspace.Zombies_Folder:GetChildren() local safezone = true if #ZombiesInGame > 3 and safezone then safezone = false workspace.GamePlayersStats.SafeZone.Script.Disabled = true for _, v in pairs(workspace.GamePlayersStats.Laser_SafeZone:GetChildren()) do for i = 0,25 do v.Transparency = v.Transparency - i/900 print(i) wait() end end elseif #ZombiesInGame < 3 and not safezone then safezone = true workspace.GamePlayersStats.SafeZone.Script.Disabled = false for _, v in pairs(workspace.GamePlayersStats.Laser_SafeZone:GetChildren()) do for i = 0,25 do v.Transparency = v.Transparency + i/900 print(i) wait() end end end end
0
Could you tell us where the output bar says the error is? This could really narrow down our search and make it easier to fix your problem. EnderGamer358 76 — 1y
0
The problem is not an error, I do not understand why the script works bad, the barrier becomes transparent, but the operation repeats itself several times and the "i" does not give the numbers in values of 1 until the end but rather "+10100" by increasing .. I do not understand how to make this script work so I ask for help to make it more reliable.. NiniBlackJackQc 593 — 1y
0
But if it comes against the rules or purpose of this site I understand. (Sorry for the mistakes I use google translation: / ..) NiniBlackJackQc 593 — 1y
0
What is the for i =1, 25 do? could you get rid of that and just put v.Transparency = 0 or .8? PoePoeCannon 484 — 1y
View all comments (4 more)
0
I want it to start from 0.8 to 0 in fade NiniBlackJackQc 593 — 1y
0
@NiniBlackJackQc All functionality is covered in my answer. Zenith_Lord 93 — 11mo
0
Please accept my answer Zenith_Lord 93 — 11mo
0
PLEASE ACCEPT MY ANSWER, IT GIVES BOTH OF US REPUTATION! Zenith_Lord 93 — 10mo

1 answer

Log in to vote
1
Answered by 11 months ago

Okay, first of all...

You don't have to use the safezone value. I see no use for it in the script other than a marker. Unless it is for debugging, I advise you to remove it. Second - your fade in/out loops are incorrect. The correct code (without safezone):

while wait() do
    local ZombiesInGame = workspace.Zombies_Folder:GetChildren()

    if #ZombiesInGame > 3 and safezone then
        workspace.GamePlayersStats.SafeZone.Script.Disabled = true
        for _, v in pairs(workspace.GamePlayersStats.Laser_SafeZone:GetChildren()) do
            for i = 0,24 do
                v.Transparency = v.Transparency - 0.032 -- This is how much it should fade out in each iteration
                print(i)
                wait()
            end
        end
    elseif #ZombiesInGame < 3 and not safezone then
        workspace.GamePlayersStats.SafeZone.Script.Disabled = false
        for _, v in pairs(workspace.GamePlayersStats.Laser_SafeZone:GetChildren()) do
            for i = 0,24 do
                v.Transparency = v.Transparency + 0.032 -- This is how much it should fade in each iteration
                print(i)
                wait()
            end
        end
    end
end
Ad

Answer this question