How do I make it "spin" into other way?

I am making an ImageLabel rotate in the same orientation, PrimaryPart of humanoid has.
But there is a problem, I want it to rotate into opposite direction. How do I do it?


Video of what I mean

while true do
wait(0.01)
	script.Parent.Rotation = game.Players.LocalPlayer.Character.PrimaryPart.Orientation.Y + 180
end

Script I am using

You quite literally just do the opposite.

while true do
wait(0.01)
	script.Parent.Rotation = game.Players.LocalPlayer.Character.PrimaryPart.Orientation.Y - 180
end

(you subtract instead of adding)

first off, thats the worst loop you can use. try the renderstepped function:

game:GetService("RunService").RenderStepped:Connect(function()
script.Parent.Rotation = -game.Players.LocalPlayer.Character.PrimaryPart.Orientation.Y
end)

my try at it is to just negate the number (which is kinda dumb but try it)

1 Like

It does the same as the adding…

@keremMCT Has the correct solution

Or, since its only changing when the primarypart changes, you can just connect it to when the primarypart does move. This uses far less processing power and is generally less intensive. Here’s the code but more clean / organised

-- use :GetService() instead, if you ever choose to obfuscate service names
local player = game:GetService("Players").LocalPlayer 
-- to avoid erroring if the character isn't loaded, wait for it to load:
local char = player.Character or player.CharacterAdded:Wait()
local main = char.PrimaryPart

-- when it changes:
main:GetPropertyChangedSignal("CFrame"):Connect(function()
    script.Parent.Rotation = -main.Orientation.Y
end)

hope this helps, but if it does work give the solution to keremMCT since they were the ones who figured out the true logic of it.

1 Like

Huge thanks man, I added + 180 to the second line and now it works!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.