Wall transpercy did not change

The problem is that when I touch the button the wall transpercy is not changeing. I think this is probarly the script.

Here is the code:

local mainGame = game.Workspace:WaitForChild("MainGame") 

local gates = mainGame:WaitForChild("Gates") -- gets the gates
local buttons = mainGame:WaitForChild("Buttons") -- gets the buttons

local function activateButton(button,touched) -- function to activate the button
	touched.Value = true
	local gate = gates:FindFirstChild(buttons.Name) -- finds child gate
	
	local duration = button:FindFirstChild("Duration") -- finds child duration
	
	local timer = duration.Value -- error here
	while timer > 0 do -- timer program
		
		print(timer)
		task.wait(1)
		timer = timer - 1
	end
	
	if gate then -- when child gate has been found
		gate.Transparency = 0.5
		gate.CanColide = true
		print("hi")

	end
	
	
	
	--task.wait(duration.Value)
	
	
	
	
	
end


for  _, button in pairs(buttons:GetChildren()) do -- a loop to get the chlidren of the buttons
	button.Touched:Connect(function(otherpart)
		local humanoid = otherpart.Parent:FindFirstChild("Humanoid") -- finds child humanoid
		local touched = button:FindFirstChild("Touched") -- finds child touched
		
		if humanoid and touched and touched.Value == false then -- activates the button if false
			activateButton(button,touched)
		end
	end)
end
2 Likes

Are there more than 1 buttons in gates? It may be picking the wrong button when you use the if gate then section of code.

Is Duration a NumberValue or another kind of value?

Do you get the timer print and the hi print?

Duration is a number value

And there is not more than one button.

Proof.

1 Like

Why the transpercy is not changed?

Was is it the order of it?

local gate = gates:FindFirstChild(buttons.Name)

Are you sure you meant to use buttons.Name here? The if statement is failing, and I believe that is the reason.

buttons.Name returns “Buttons”.

I changed it to gates.Name but I got a new error

Here

CanColide is not a valid member of Part “Workspace.MainGame.Gates.Gates”

So what should I do?

It’s a spelling error. Try CanCollide, not CanColide.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.