Hi guys, i’ve made this script that consent to open a chest for a player, and it works fine, but i want it to tween instead of using “PivotTo” function, the pivot cframe is different from the actual cframe, so i have to use pivot instead of just tweening cframe
Any Help?
local rs = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local remotes = rs:WaitForChild("Remotes")
local OpenChest = remotes:WaitForChild("ApriChest")
local debounce = false
local Info = TweenInfo.new(
1,
Enum.EasingStyle.Elastic,
Enum.EasingDirection.Out
)
OpenChest.OnClientEvent:Connect(function(chestCover, proximityPrompt)
if debounce == false then
debounce = true
proximityPrompt.Enabled = false
local currentPivot = chestCover:GetPivot()
chestCover:PivotTo(currentPivot * CFrame.Angles(0, math.rad(-120),0))
wait(4)
chestCover:PivotTo(currentPivot)
debounce = false
proximityPrompt.Enabled = true
end
end)
I have tried this before and there have been many errors, even if what I tried must’ve theoretically worked.
I would create an invisible “PartA” and “PartB”, the CFrames to set the chest position and orientation to, and an attribute named “CurrentCFrame”, with the value being, obviously, a CFrame.
Then, you can tween the attribute value, and then hook a :GetPropertyChangedSignal() onto that value, to then set the CFrame on the chest.
Kind of unnecessary and complicated, but it works-