Hey, I am trying to create sort of an elevator rig using rope constraints. I want the elevator to move with a sort of easing style (slow, fast, slow [inOut]) into its final position where the ropeConstraints length is 0.
I thought since RopeConstraint.Length is just a number value, the tweenService could handle it. But I get an error telling me:
20:27:59.030 - Unable to cast value to Object
This is my code:
local ropeSystem = script.Parent.Parent.ropeSystem
local door = script.Parent.Parent.doorModel.door
local endPos = ropeSystem.endPos
local startPos = ropeSystem.startPos
local rope = endPos:FindFirstChild("RopeConstraint")
local f = false
local TweenService = game:GetService("TweenService")
local tween = TweenService:Create(rope.Length, TweenInfo.new(15, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {number = 0})
script.Parent.ClickDetector.MouseClick:connect(function(plr)
if plr and f == false then
f = true
wait(1.5)
local angularVel = game.ReplicatedStorage.BodyAngularVelocity:Clone()
angularVel.Parent = door --close door
wait(2)
if ropeSystem then
if door:FindFirstChild("BodyAngularVelocity")then
angularVel:Remove()
wait()
if rope then
--[[local magnitude = rope.Length
for i = magnitude, 0, -.6 do
wait()
rope.Length = i
end
wait(2)--]]
tween:Play() -- Tween
angularVel.Parent = door
door.HingeConstraint.TargetAngle = 0
angularVel.AngularVelocity = Vector3.new(0,-2,0) -- open door
end
end
end
end
end)
Why is this not working?