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

I have three scripts and none of them work...why?

This one is supposed to open a gate:

local gate = script.Parent

Game.Players.PlayerAdded:connect(function(plr)
	if plr:GetRankInGroup(947529) == 14 then
		plr.Chatted:connect(function(msg)
		if msg == ":Close:" then
				for i=1, 22.5, 1 do 
    			gate.Position = gate.Position - Vector3.new(0,0.4,0)
   				 wait(0.1)
				end
			end
		end)
	end
end)

.................................... This one opens it:

local gate = script.Parent

Game.Players.PlayerAdded:connect(function(plr)
	if plr:GetRankInGroup(947529) == 14 then
		plr.Chatted:connect(function(msg)
		if msg == ":Open:" then
				for i=1, 22.5, 1 do
    			gate.Position = gate.Position + Vector3.new(0,0.4,0)
				 wait(0.1)
				end
			end
		end)
	end
end)

...................................... This one opens a different gate, waits 5 seconds, then closes it:

local gate = script.Parent

Game.Players.PlayerAdded:connect(function(plr)
	if plr:GetRankInGroup(947529) == 14 then
		plr.Chatted:connect(function(msg)
		if msg == ":Passway:" then
				for i=1, 22.5, 1 do
    			gate.Position = gate.Position + Vector3.new(0,0.4,0)
				 wait(0.1)
				wait(5)
				for i=1, 22.5, 1 do
    			gate.Position = gate.Position - Vector3.new(0,0.4,0)
				 wait(0.1)
					end
				end
			end
		end)
	end
end)

None of them work...so please help! Thanks

1 answer

Something I just thought you should keep in mind is that there should be a debounce so if the door is already opening someone can't run the opening script and glitch the door up, or that you can only close it when it is opened and vise versa. But that isn't the point, you want help lol. The problem with your script is that you said i = 1,22.5,1 which means that, you are counting by 1's, from 1 to 22.5. See what I'm getting at? The script is like "WAIT A MINUTE, (22.5-1) is not evenly divisible by 1! Error. I would suggest changing the incriment value to .5, speeding up the waits to wait(.05) and everything should work smoothly.

1 comment

0

I tried that....it still won't move...

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