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

I need help with position/cframe stuff?

Asked by
VitroxVox 884 Moderation Voter
4 years ago
Edited 4 years ago

Let's start off with I'm really bad with cframe and position stuff, i've made a gate that opens & closes but because i'm not really a genius i made it for a specific position the problem with this is that if i put the gate somewhere else it won't work, so i need help to make it use the position of the gate and lower it , then lift it!

Current script:

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
    5, -- Time
    Enum.EasingStyle.Linear, -- EasingStyle
    Enum.EasingDirection.Out, -- EasingDirection
    -1, -- RepeatCount (when less than zero the tween will loop indefinitely)
    true, -- Reverses (tween will reverse once reaching it's goal)
    0) --delay time

function opengate()

local tween = TweenService:Create(gate, tweenInfo, {Position = Vector3.new(53.315, 14.45, 46.329)})

tween:Play()
wait(5)
tween:Cancel()
end

function closegate()

local tween = TweenService:Create(gate, tweenInfo, {Position = Vector3.new(53.315, 4.795, 46.329)})

tween:Play()
wait(5)
tween:Cancel()

end

I didn't include some stuff in the script such as the remote event and the part that says where the gate is cause it's pretty useless, the gate is a part.

1 answer

Log in to vote
1
Answered by
St_vnC 330 Moderation Voter
4 years ago

To move the gate with CFrame you do CFrame.new

for i = 1,99,1 do
      gate.CFrame = CFrame.new(gate.CFrame.X,gate.CFrame.Y + .1,gate.CFrame.Z)
      wait()
end
gate.CFrame = CFrame.new(gate.CFrame.X,14.45,gate.CFrame.Z) --This makes nothing is out of place

Actually think Tweening is more useful than CFrame in this context

Ad

Answer this question