Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Turn a player through a script?

I want to turn a player through a script. I've tried setting the rotation for Torso, but that kills the player, and HumanoidRootPart, which does a weird effect that raises the part and detaches it from the player.

I've tried CFrame.Angles, but I can't seem to get the right amount that won't make the player spaz out.

I'm using this so I can let the players move their mouse to move their character, but it just doesn't seem to work.

How can I do this?

1 answer

There's a nifty little add-on to the original CFrame operator that's created like this:

local point, lookvector = Vector3.new(), Vector3.new()
local cframe = CFrame.new(point, lookvector)

Basically, the first value works like setting the position of the torso, and the second value is where the CFrame points.

local mouse = game.Players.LocalPlayer:GetMouse()
repeat wait() until game.Players.LocalPlayer.Character

game:GetService("RunService").RenderStepped:connect(function()
	game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(game.Players.LocalPlayer.Character.Torso.CFrame.p, mouse.Hit.p)
end)

Hopefully this works, if you have any other questions, you can consult me through my ROBLOX account. Sorry if some wording is bad, English is not my first language. Thanks!

3 comments

0

Unfortunately, this will not work with FilteringEnabled. It will only turn the player for the player themselves, not others.

0

Ah, would have been nice to know that your game had FE beforehand, perhaps you could use a localscript to set a variable inside of the player to the mouse's position, and use a server script to change the orientation.

0

Theoretically that would work, however that would cause pretty big lag considering it would pretty much be running that function several times a second.

This discussion is preserved as it was. New answers, comments, and votes are closed.