Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.