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.

01local TweenService = game:GetService("TweenService")
02local Time = 2
03 
04script.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), {Position = game.Workspace.storageroomdooropen.Position, Orientation = game.Workspace.storageroomdooropen.Orientation}):Play()
09    end
10end)

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:

01local TweenService = game:GetService("TweenService")
0202  local Time = 2
0303  
0404  script.Parent.ProximityPrompt.Triggered:Connect(function(Player)
0505      if Player:WaitForChild("Backpack"):FindFirstChild("Key") then
0606          script.Parent.ProximityPrompt.Enabled = false
0707  
0808          TweenService:Create(script.Parent.Parent.storageroomdoorclosed,TweenInfo.new(Time, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {CFrame = game.Workspace.storageroomdooropen.CFrame}):Play()
0909      end
1010  end)
Ad

Answer this question