Pressure Plate Issues

So I made this script
Gate = script.Parent.Parent.Gate
on = false
script.Parent.Touched:Connect(function(Hit)
if Hit:FindFirstChild(“Block”) then
on = true
wait(3)
on = false
end
while on == false do
Gate:TweenSize(Vector3.new(13.5, 14.5, 3.5),“Out”, “Bounce”,1,true)
wait(1)
Gate:TweenSize(Vector3.new(13.5, 14.5, 3.5),“Out”, “Bounce”,1,true)
end

		while on == true do
			Gate:TweenSize(Vector3.new(13.5, 1.5, 3.5),"Out", "Bounce",1,true)
			wait(1)
		end
end)

So basically what I’m trying to do is make it so when they step on the pressure plate and are stepping on it the door starts to tween upwards and when they don’t stand on it the door starts to tween downwards. I’m also trying to make it so that Blocks can trigger the preasure plate. If anyone could help me figure out whats wrong with this I’d really appreciate it.

What’s the issue right now? What happens? Is there anything in the output? These are things you should consider before posting.

2 Likes

In your while loop it says

while on == false do.

I remember when I was making a script I had a boolean value that I checked to run a script. I wrote:

if bool == false then
--run stuff
else
do a different thing.

And it didn’t work. I switched around the else and if state statements and changed false to true and it worked, I assume because statements only run if they are true.

What I suggest doing to your script is using:

while true do
     if on == true then
      Gate:TweenSize(Vector3.new(13.5, 1.5, 3.5),"Out", "Bounce",1,true)
      wait(1)
else
Gate:TweenSize(Vector3.new(13.5, 14.5, 3.5),“Out”, “Bounce”,1,true)
wait(1)
Gate:TweenSize(Vector3.new(13.5, 14.5, 3.5),“Out”, “Bounce”,1,true)
end
end

I might have made a few errors with this script because it is pretty difficult to script on the devforum cause it doesn’t auto-fill for you.

If you use roblox studio like me, it is much easier to program and get autocorrections.

Cast a ray up from the pressure plate, or down from the player and blocks and see if it hits one or the other, then start the door tween stuff.

yeah i do of course but i cant be bothered to go on studio

I completely forgot I’ll go get those for you.

You could open studio at the same time that you open dev forum, it’s much nicer to write your code there. Oh and you can do quick bugfixes.