Hello,
I need some help with a CFrame script.
I want to make the script rotate the part until is back at the default Orientation.
Issue: The script works but nothing happens once the orientation is default.
Debounce = false
script.Parent.ClickDetector.MouseClick:Connect(function()
if not Debounce then
Debounce = true
repeat
game.Workspace.Model.Main.Union.CFrame = game.Workspace.Model.Main.Union.CFrame * CFrame.fromEulerAnglesXYZ(0,0.1,0)
wait(0.01)
until game.Workspace.Model.Main.Union.Orientation == Vector3.new(0,0,0)
Debounce = false
end
end)
With the script i made, do this:
local A = game.TweenService
Debounce = false
script.Parent.ClickDetector.MouseClick:Connect(function()
if not Debounce then
Debounce = true
local T = A:Create(game.Workspace.Model.Main.Union, TweenInfo.new(5), {Orientation = Vector3.new(0,360,0)}):Play()
T.Completed:Connect(function()
Debounce = false
end)
end
end)
TweenService asks you to set a Instance, and a Property to Change before Playing
_T:Create(_B.Base, -- My Part that i used
TweenInfo.new(2), -- Tween Information, Only the Speed is there
{Orientation = Vector3.new(0,360,0)} -- Sets Only the Orientation (Rotation)
):Play() -- Plays The Tween
create a new cframe with a angle and position but in a variable.
local cf = CFrame.new(pos) * CFrame.Angles(math.rad(x), math.rad(y), math.rad(z))
local ts = game:GetService('TweenService')
local ti = -- your tween info
ts:Create(youritem, ti, {CFrame = cf}):Play()
since your trying to make it go back to default, set it to 0,0,0 or any value you want.