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

Why does this keep turning the orientation back to 0?

Asked by 4 years ago

So I have a gate script which works all good, but for some reason, When I click the gate, it moves up, but turns it into the orientation of 0, we need the orientation to 0,90,0. So we did that after each tween played. But still when we click it, it turns it back to 0 orientation. Here is the server script:

local TweenService = game:GetService("TweenService")
local door1 = script.Parent.Parent.Part1
local tweeningInformation = TweenInfo.new(
    2,   
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local door1Open = {CFrame = CFrame.new(-161.498, 15.143, -125.72)}
local door1Close = {CFrame = CFrame.new(-161.498, 5.666, -125.72)}
local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
 local open = false
script.Parent.ClickDetector.MouseClick:Connect(function()
    if not open then 
    open = true
    tween1open:Play()
door1.Orientation = Vector3.new(0,90,0)
    else
    tween1close:Play()
door1.Orientation = Vector3.new(0,90,0)
open = false
    end
end)
1
CFrame.new(pos) creates a cframe with a position matrix of `pos` and a default rotation matrix theking48989987 2147 — 4y
1
if you want to keep the rotation matrix, you can get it by doing thing.Cframe - Thing.CFrame.Position, then add that to the new cframe created from the position theking48989987 2147 — 4y
0
Uh can you give an example in a script? Kinda hard to understand. Mrmonkeyman120 65 — 4y

Answer this question