Hey everyone,
I’ve created a camping stove (its size has been increased to make it easier to see), and its On/Off dial feature constantly tweens incorrectly.
With tweens and CFrames, I understand that tweening moves the centre-most part to the destination. I’ve tried setting the PrimaryPart of the dial as the tab, yet the issue persisted. I looked at this post on the Devforum, yet the solution didn’t work for me.
Ideally, the dial would alternate between a horizontal (Off) and vertical (On) appearance upon click.
Here is my script for critique:
local TweenService = game:GetService("TweenService")
local Stove = script.Parent
local GoldDial = Stove.GoldDial
local DialPrimary = GoldDial.PrimaryPart
local ClickDetector = GoldDial.Clicker.ClickDetector
local DialOriginalCFrame = DialPrimary.CFrame
local On = false
local tweenInfo2 = TweenInfo.new(
0.25,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In
)
local function DialOpen()
local TweenDialOpen = TweenService:Create(DialPrimary, tweenInfo, {CFrame = DialPrimary.CFrame * CFrame.Angles(math.rad(90), 0, 0)})
TweenDialOpen:Play()
On = true
end
local function DialClose()
local TweenDialClose = TweenService:Create(DialPrimary, tweenInfo, {CFrame = DialOriginalCFrame * DialPrimary.CFrame.Rotation})
-- Tried {CFrame = DialPrimary.CFrame * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))})
TweenDialClose:Play()
On = false
end
ClickDetector.MouseClick:Connect(function()
if not On then
DialOpen()
print("On")
elseif On then
DialClose()
print("Off")
end
end)
Here is the hierarchy order for the dial:
The PrimaryPart is the part labelled “Hinge”, which, for reference, is located inside of base of the dial structure.