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

CFraming not working, why? [Updated]

Asked by 9 years ago

I have a script which is meant to move the model "PLT", short for platform, 9 studs back and 25 to the left, but it doesn't work? Does it work with Models or just parts/unions????

function click()
if(script.Parent.Status.Value)=="Closed" then
script.Parent.Status.Value="Opening"
movements=45
speed=0.2
for i=1,movements do
wait(0.01)
script.Parent.PLT.CFrame=script.Parent.PLT.CFrame + Vector3.new(0,0,speed);
end

sidemoves=275
sidespeed=0.2
for i=1,sidemoves do
wait(0.01)
script.Parent.PLT.CFrame=script.Parent.PLT.CFrame + Vector3.new(sidespeed,0,0)
end
script.Parent.Status.Value="Open"



--negative movement
elseif(script.Parent.Status.Value)=="Open" then
script.Parent.Status.Value="Closing"

sidemoves=275
sidespeed=0.2
for i=1,sidemoves do
wait(0.01)
script.Parent.PLT.CFrame=script.Parent.PLT.CFrame + Vector3.new(-sidespeed,0,0)
end


movements=45
speed=0.2
for i=1,movements do
wait(0.01)
script.Parent.PLT.CFrame = script.Parent.PLT.CFrame + Vector3.new(0,0,-speed);
end
script.Parent.Status.Value="Closed"
end
end
script.Parent.Control1.SurfaceGui.TextButton.MouseButton1Click:connect(click)
script.Parent.Control2.SurfaceGui.TextButton.MouseButton1Click:connect(click)

[UPDATE] Is there a way I could get the model's children and apply this script to them?

Answer this question