#Why Tween doesn't change pivot
1 messages · Page 1 of 1 (latest)
--// Service
local TS = game:GetService("TweenService")
--// Stats
local Prompt = script.Parent
local Lever = script.Parent.Parent
local Delayed = false
--// Tween
local TInfo = TweenInfo.new(1, Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,true)
local TGoal = {
CFrame = Lever.CFrame * CFrame.Angles(math.rad(90),0,0)
}
--// Roll
local function Roll()
local RollTween = TS:Create(Lever, TInfo, TGoal);RollTween:Play()
end
Prompt.Triggered:Connect(function()
if Delayed == false then
Delayed = true
task.delay(5,function()
Delayed = false
end)
Roll()
end
end)
Because your tweening the CFrame directly
You can only make use of the pivot by using :PivotTo()
You could also offset the goal by the pivot
So I need to use :PivotTo() for Tween to rotate the lever from where I want?
You could do that or you could read the pivot property and use it to offset the target cframe
something like this (I haven't tested it and am a bit sleepy so not 100% sure if I did this right)
local TGoal = {
CFrame = (Lever:GetPivot() * CFrame.Angles(math.rad(90),0,0)):ToWorldSpace(Lever:GetPivot():ToObjectSpace(Lever.CFrame))
}
Thanks a lot it kinda works I think the problem here is I couldn't set pivot correctly
But I didn't understand what you did here?
can you explain
@tawny sable if you are free can you?
Lever:GetPivot()Get the lever's pivot's cframe ->PVPV:ToObjectSpace(Lever.CFrame)Convert the pivot to be relative to the lever's cframe. ->RPVCFrame.Angles(math.rad(90),0,0))Define how much the lever should be roated (or translated) ->ROTROT:ToWorldSpace(RPV)Effectively rotateRPVbyROT
I would recomend reading the docs for cframes
https://create.roblox.com/docs/reference/engine/datatypes/CFrame#ToWorldSpace