How to add +90 degrees everytime I press E

So what I am trying to do is so that everytime you press E, the wedge moves +90 degrees.

However, in the script below I thought that doing + Vector would do an addition to my current orientation but in reality all it did was move it to an orientation of 90.

https://gyazo.com/7700d92803ef95be1e8eaa69a667da12

local TweenService = game:GetService("TweenService")
local Wedge = script.Parent

local TurnInfo = TweenInfo.new(

	1.668,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In,
	0,
	false,
	0
)


Spin1 = TweenService:Create(Wedge,TurnInfo, {Orientation = Wedge.Orientation + Vector3.new(0, 90, 0)})


Wedge.ProximityPrompt.Triggered:Connect(function(player)
	Spin1:Play()
end)

I thought this would be an easy thing to fix but I couldn’t find a post of additions to orientations.

Appreciate the help

1 Like

You can use CFrames and do it like that {CFrame = Wedge.CFrame * CFrame.Angles(0,math.rad(90),0)}

local TweenService = game:GetService("TweenService")
local Wedge = script.Parent

local TurnInfo = TweenInfo.new(

	1.668,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local function getWedgeOrienatation()
	return Wedge.Orientation or Vector3.new(0, 0, 0)
end


Spin1 = TweenService:Create(Wedge,TurnInfo, {Orientation = getWedgeOrienatation() + Vector3.new(0, 90, 0)})


Wedge.ProximityPrompt.Triggered:Connect(function(player)
	Spin1:Play()
end)

This was because you were just getting the original orientation of the wedge as opposed to updating it each time it is rotated, I’ve made a function which when called returns the current orientation of the wedge, for it to then be used in the tween.

Didn’t seem to work, it basically achieved the same result as before

https://gyazo.com/f7790ad92be06e5d62078e12f2701679

All it did was move the wedge once to the orientation of 90 degrees and didn’t move more.

local TweenService = game:GetService("TweenService")
local Wedge = script.Parent

local TurnInfo = TweenInfo.new(

	1.668,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

Wedge.ProximityPrompt.Triggered:Connect(function(player)
	local Spin1 = TweenService:Create(Wedge,TurnInfo, {Orientation = Wedge.Orientation + Vector3.new(0, 90, 0)})
	Spin1:Play()
end)

The solution is already given by Forummer right above me. The issue was because you’ve already defined Spin1 in the script & just refer to the same information over & over. Putting it inside the function will always set/update the infomation you want to run. Referring to a already set variable won’t update it, you’ll have to update it yourself.