Having this issue right now where I’m trying to tween a part to rotate to the exact coordinates I give it. However it doesn’t. I know the solution is probably simple, but I’m confused. Here’s my code:
local number = 1
local correctNumber = 3
local statue = workspace.School.Important.PuzzleStatues.Statues.Statue2
local tweenService = game:GetService("TweenService")
local positions = {
script.Parent.Parent.CFrame * CFrame.fromOrientation(0,math.rad(-69.907), 0),
script.Parent.Parent.CFrame * CFrame.fromOrientation(0, math.rad(8.162), 0),
script.Parent.Parent.CFrame * CFrame.fromOrientation(0, math.rad(90.512), 0),
script.Parent.Parent.CFrame * CFrame.fromOrientation(0, math.rad(-154.59), 0),
}
function light(on)
for _, v in pairs(statue.Flame:GetChildren()) do
if v:IsA("ParticleEmitter") or v:IsA("PointLight") then
v.Enabled = on
end
end
end
local debounce = false
script.Parent.Triggered:Connect(function(player)
if debounce == false then
debounce = true
script.Parent.Enabled = false
script.Parent.Parent.StoneMoving:Play()
local tween = tweenService:Create(script.Parent.Parent, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {CFrame = positions[number]})
tween:Play()
tween.Completed:Wait()
number += 1
if number == correctNumber then
light(true)
elseif statue.Flame.CandleFire.Enabled == true then
light(false)
end
if not positions[number] then
number = 1
end
debounce = false
script.Parent.Enabled = true
end
end)
local TweenService = game:GetService("TweenService")
local Statue = workspace.School.Important.PuzzleStatues.Statues.Statue2
local Number = 1
local CorrectNumber = 3
local Debounce = false
local Positions = {
["1"] = CFrame.fromOrientation(0, math.rad(-69.907), 0);
["2"] = CFrame.fromOrientation(0, math.rad(8.162), 0);
["3"] = CFrame.fromOrientation(0, math.rad(90.512), 0);
["4"] = CFrame.fromOrientation(0, math.rad(-154.59), 0)
}
function light(on)
for _, v in pairs(Statue.Flame:GetChildren()) do
if v:IsA("ParticleEmitter") or v:IsA("PointLight") then
v.Enabled = on
end
end
end
local function Tweening()
local TweenInfos = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local Tween = nil
local Goal = {}
for Key, Value in pairs(Positions)do
if tonumber(Key) == Number then
Goal.CFrame = Value
end
end
Tween = TweenService:Create(script.Parent.Parent, TweenInfos, Goal)
Tween:Play()
Tween.Completed:Wait()
end
local function NumberCheck()
local CheckPos = #Positions
if Number == CorrectNumber then
light(true)
elseif Statue.Flame.CandleFire.Enabled == true then
light(false)
end
if Number > CheckPos then
Number = 1
end
end
script.Parent.Triggered:Connect(function(player)
if Debounce == false then
Debounce = true
script.Parent.Enabled = false
script.Parent.Parent.StoneMoving:Play()
Tweening()
Number += 1
NumberCheck()
Debounce = false
script.Parent.Enabled = true
end
end)