Hi fellow Scripters

I have a gate model that I am having trouble with. It runs on studio mode but not on ROBLOX Client.

Here is the model: https://www.roblox.com/library/582381368/New-Gate-WIP

It runs on normal script. Not local script. I have done many stuff. Followed a few guides and yet turn out the same.

There are two scripts. Open and Close

Here is the Open Script

-- Variables --
opening = false
right = script.Parent.Parent.Parent.Parent.Parent.GateRight
left = script.Parent.Parent.Parent.Parent.Parent.GateLeft
open = script.Parent
close = script.Parent.Parent.Close
button = script.Parent



-- Main -- 
function onClick()
	if opening == false then
		opening = true
		open.Visible = false
		for i = 1,90 do
		
			for i,v in pairs( right:GetChildren() ) do
   				v.CFrame = v.CFrame + Vector3.new (-.2,0,0)
			end
			
			for i,v in pairs( left:GetChildren() ) do
   				v.CFrame = v.CFrame + Vector3.new (.2,0,0)
			end
		
			wait(0.01)
		end
		opening = false
		close.Visible = true
	end
end

button.MouseButton1Click:connect(onClick)

And here is the close script:

-- Variables --
closing = false
right = script.Parent.Parent.Parent.Parent.Parent.GateRight
left = script.Parent.Parent.Parent.Parent.Parent.GateLeft
button = script.Parent
open = script.Parent.Parent.Open
close = script.Parent



-- Main -- 
function onClick()
	if closing == false then
		closing = true
		close.Visible = false
		for i = 1,90 do
		
			for i,v in pairs( right:GetChildren() ) do
   				v.CFrame = v.CFrame + Vector3.new (.2,0,0)
			end
			
			for i,v in pairs( left:GetChildren() ) do
   				v.CFrame = v.CFrame + Vector3.new (-.2,0,0)
			end
		
			wait(0.01)
		end
		closing = false
		open.Visible = true
	end
end

button.MouseButton1Click:connect(onClick)

Please do help.Your help is appreciated.

1 comment

0

For better coding practice, please put local before your first variables and others