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.
thats because everytime the number goes more or equal than 360 it goes back to 0, and since you tween it, its visible.
fix :
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)
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
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!