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

I'm making my first ability for my game. Why isn't the elseif working?

Asked by 4 years ago
Edited 4 years ago

In the second part of the ifMaster and elseMaster, the elseif v.ClassName == "Accessory" then v:GetChildren().Transparency = 1 won't work. If you can see any other errors throughout the script I'd appreiciate if they were corrected aswell. ps (Sorry about the incorrect code format, the box in the question isn't long enough to support it)

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage.Remotes:WaitForChild("hazeRemote")
local Endurance =                   game.ReplicatedStorage.PlayerInventories.ExamplePlayer.otherValues.Endurance.Value
local Mastery = game.ReplicatedStorage.PlayerInventories.ExamplePlayer.otherValues.mastery.Value
local usingPower = game.ReplicatedStorage.PlayerInventories.ExamplePlayer.otherValues.usingPower.Value

local function ifMaster(player)
    if Mastery == 12 then
        for Index, v in pairs (player.Character:GetChildren()) do
             if v.ClassName == "MeshPart" or v.Name == "Head" then v.Transparency = 1
             elseif v.ClassName == "Accessory" then  v:GetChildren().Transparency = 1 
                    end
                end
            end
        end

local function elseMaster(player)
     if Mastery ~= 12 then
            for Index, v in pairs (player.Character:GetChildren()) do
                if v.ClassName == "MeshPart" or v.Name == "Head" then v.Transparency = .9
                elseif v.ClassName == "Accessory" then  v:GetChildren().Transparency = .9 
                    end
                end
            end
        end

remote.OnServerEvent:Connect(function(player)
        if usingPower == false then 
            usingPower = true
            ifMaster(player)
            elseMaster(player)
                while usingPower == true do 
                    Endurance = Endurance - 1
                    wait(1)
                        if Endurance == 0 then
                            break 
                        end
                    end

        elseif usingPower == true then


        end
    end)

1 answer

Log in to vote
1
Answered by
Rinpix 639 Moderation Voter
4 years ago

If you want to set the transparency of each child of the accessory, you'll have to iterate through the accessory.

for i, v in pairs(Accessory:GetChildren()) do
    if v:IsA("BasePart") then
        v.Transparency = 1
    end
end
Ad

Answer this question