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

Why does this door spin with TweenService?

Asked by 2 years ago
Edited 2 years ago

So, my problem is I have a door with a proximityprompt, and a key, when I use a key the door opens, like doors usually do. But the door doesn't just rotate 90 degrees, it rotates a full 360 degrees and then goes to the "storageroomdoorclosed" door. And it's not closing the right way it's going left 360 degree, when the right way would be: going right and only rotating 90 degree.

local TweenService = game:GetService("TweenService")
local Time = 2

script.Parent.ProximityPrompt.Triggered:Connect(function(Player)
    if Player:WaitForChild("Backpack"):FindFirstChild("Key") then
        script.Parent.ProximityPrompt.Enabled = false

        TweenService:Create(script.Parent.Parent.storageroomdoorclosed,TweenInfo.new(Time, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Position = game.Workspace.storageroomdooropen.Position, Orientation = game.Workspace.storageroomdooropen.Orientation}):Play()
    end
end)

1 answer

Log in to vote
0
Answered by 2 years ago

I dont know to fix it, BUT I do know another way to do it. You are going to wanna use CFrame. CFrame is just the EXACT position of a object. Instead of doing all of those properties, do this:

local TweenService = game:GetService("TweenService")
02  local Time = 2
03   
04  script.Parent.ProximityPrompt.Triggered:Connect(function(Player)
05      if Player:WaitForChild("Backpack"):FindFirstChild("Key") then
06          script.Parent.ProximityPrompt.Enabled = false
07   
08          TweenService:Create(script.Parent.Parent.storageroomdoorclosed,TweenInfo.new(Time, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {CFrame = game.Workspace.storageroomdooropen.CFrame}):Play()
09      end
10  end)

Ad

Answer this question