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.
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.