Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this if statement + while loop not working?

Asked by 8 years ago
while true do
    if script.Parent.Parent.Value.Value == true then
        script.Parent.ParticleEmitter.Enabled = false
        script.Parent.Transparency = 1
    elseif script.Parent.Parent.Value.Value == false then
        script.Parent.Transparency = 0
        script.Parent.ParticleEmitter.Enabled = true
        if script.Parent.Script2 == nil then
            local a = script.Parent.Folder.Script2:Clone()
            a.Parent = script.Parent
        end
    end
    wait(0.01)
end

I'm trying to have a value in script.Parent.Parent.Value that decides whether this part will be transparent or not. It's not working. If it helps, the Value is in game.Workspace and the part trying to use the value in game.Workspace.Part. The if statement within the elseif statement is meant to find out if there's already a script called Script2 in the parent of the folder its in. If it doesn't exist, it is meant to clone the script and put it inside the folder's parent. Can anyone explain to me why this is not working correctly?

1
Do your nilchecks with FindFirstChild User#6546 35 — 8y
0
XD pls do no use this "script.Parent.Parent.Value.Value == true" , just use "script.Parent.Parent.Value.Value". An if statment only runs if true, you are doing if true = true then. User#5423 17 — 8y
0
thanks for advice Extraordinarius -5 — 8y

Answer this question