Hello developers !!!
I am making a game which has a character purchase system, so, in the menu where one of the ones you have is equipped, it takes the camera to a gallery with your inventory and the selected skin on opposite sides, so, I want you to When the player keeps the click, if you move the mouse to the right the character rotates to the right and to the left the same, and when you stop holding down, it does not rotate, I already made a system, but it is difficult to control the rotations and not turning right, any help?
I made code similar to this but drags the camera about instead of a player but ive tried to recode it so it can work for you. obviously change Dummy to your player u want to rotate and ive also not tested the angle values your gunna have to use trial and error to decide what works.
(Also this code is a local script)
UIS.InputBegan:Connect(function(a)
if a.UserInputType == Enum.UserInputType.MouseButton1 then
MouseDown = true
MouseOrigin = Mouse.Hit.p
end
end)
UIS.InputEnded:Connect(function(a)
if a.UserInputType == Enum.UserInputType.MouseButton1 then
MouseDown = false
MouseOrigin = nil
end
end)
spawn(function()
Mouse.Move:Connect(function()
if MouseDown == true then
local Position = Vector2.new(Mouse.X, Mouse.Y)
local Size = Vector2.new(Mouse.ViewSizeX, Mouse.ViewSizeY)
local NormalizedPosition = Position / Size
local Rotation = NormalizedPosition.X/2
game.Workspace.Dummy:SetPrimaryPartCFrame(game.Workspace.Dummy.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(Rotation), 0))
end
end)
end)
(I Know this isnt what its ment to do but its as close as i can get right now. maybe you can fix it up, or someone else can write something better, goodluck!)