Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this door spin with TweenService?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.