Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sliding Doors flings when I touch it?

Asked by 5 years ago
Edited 5 years ago

The doors moves but not in the correct direction.It either flings away or slides in a 45 degrees angle.

I used two scripts for each door,one for the Right and Left.

Right Door script

debounce = false

script.Parent.Touched:connect(function(hit)
if debounce == true then return end
debounce = true
if hit.Parent:FindFirstChild("Humanoid") then
for i = 1,40 do
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(-.5,0,0)
wait()
end

wait(1)
for i = 1,40 do
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(.5,0,0)
wait()
end
end
debounce = false
end)

Left Door script

debounce = false

script.Parent.Touched:connect(function(hit)
if debounce == true then return end
debounce = true
if hit.Parent:FindFirstChild("Humanoid") then
for i = 1,40 do
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(.5,0,0)
wait()
end

wait(1)
for i = 1,40 do
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(-.5,0,0)
wait()
end
end
debounce = false
end)

The Right and Left door's script is the same except the Vectors are different. Any help?

0
I don't think you are able to add a CFrame with a Vector3. BTW, please indent your code! saSlol2436 716 — 5y
0
Are they anchored? Oficcer_F 207 — 5y
0
No they aren't anchored. rochel89 42 — 5y

Answer this question