local plr = script.Parent.Parent.Parent.Name
local TweenService = game:GetService("TweenService")
local ang = 0
while wait() do
local look = game.Workspace.Camera.CFrame.LookVector
local angle = math.atan2(look.X, look.Z)
ang = -math.deg(angle) % 360
local goal = {}
goal.Rotation = ang
local tweenInfo = TweenInfo.new(0.6)
local tween = TweenService:Create(script.Parent.ImageLabel, tweenInfo, goal)
tween:Play()
script.Parent.TextLabel.Text = ang
end
Simple add: tween.Completed:wait()
Make sure it’s after you play it, as nothing below will run. I’d suggest putting it just above the end of the loop.
Right now, you don’t actually wait for the current tween to run before attempting to tween it again. This will make the loop wait until the tween completed before looping again.
You should explain the issue, a potential fix and leave them to implement it. You can provide an example but a completely fixed version of the code which he can copy paste isn’t allowed.
local plr = script.Parent.Parent.Parent.Name
local TweenService = game:GetService("TweenService")
local ang = 0
local tween;
while wait() do
local look = game.Workspace.Camera.CFrame.LookVector
local angle = math.atan2(look.X, look.Z)
ang = -math.deg(angle) % 360 -- also try -(math.deg(angle) % 360)
local goal = {}
goal.Rotation = ang
local tweenInfo = TweenInfo.new(0.6)
if tween then
tween:Cancel()
end
tween = TweenService:Create(script.Parent.ImageLabel, tweenInfo, goal)
tween:Play()
script.Parent.TextLabel.Text = ang
end
Hi, I just talked to you in DM’s but i’m thirsty for that solution.
If I was making this I would do it a different way.
First I would create a value in the GUI called North, this would be a Vector3Value and u would put the value as ‘1, 0, 0’. Then I would create a value to store the degrees it’s currently set at this can be a NumberValue and set it to 0.
CODE
game:GetService("RunService").RenderStepped:Connect(function(Delta)
local Character = game.Players.LocalPlayer.Character
if ( not Character ) then
return
end
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if ( not HumanoidRootPart ) then
return
end
local OffsetX, OffsetY, OffsetZ = CFrame.new(Vector3.new(), script.Parent.North.Value):ToEulerAnglesXYZ()
script.Parent.Degrees.Value = math.floor(-HumanoidRootPart.Orientation.Y + 180 - math.deg(OffsetY))
end)
In your other script you can tween the GUI to the degree value!
local plr = script.Parent.Parent.Parent.Name
local TweenService = game:GetService("TweenService")
local ang = 0
local tween;
while wait() do
local look = game.Workspace.Camera.CFrame.LookVector
local angle = math.atan2(look.X, look.Z)
ang = math.deg(angle) % 360 -- also try -(math.deg(angle) % 360)
local goal = {}
goal.Rotation = ang
local tweenInfo = TweenInfo.new(0.6)
if script.Parent.ImageLabel.Rotation >= 270 and goal.Rotation <= 90 then
if tween then
tween:Cancel()
end
script.Parent.ImageLabel.Rotation = 0
tween = TweenService:Create(script.Parent.ImageLabel, tweenInfo, goal)
tween:Play()
elseif script.Parent.ImageLabel.Rotation <= 90 and goal.Rotation >= 270 then
if tween then
tween:Cancel()
end
script.Parent.ImageLabel.Rotation = 360
tween = TweenService:Create(script.Parent.ImageLabel, tweenInfo, goal)
tween:Play()
else
if tween then
tween:Cancel()
end
tween = TweenService:Create(script.Parent.ImageLabel, tweenInfo, goal)
tween:Play()
end
script.Parent.TextLabel.Text = ang
end
This works but it snaps. I tried making it tween to 359.99 then setting the rotation to 0, then proceeding the tween but it seems to not work. Do what you can with the script