Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Turn a player through a script?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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!

0
Unfortunately, this will not work with FilteringEnabled. It will only turn the player for the player themselves, not others. Kampfkarren 215 — 8y
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. HollowMariofan 104 — 8y
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. Kampfkarren 215 — 8y
Ad

Answer this question