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

Works with Play Solo but not on the Server?

local localPlayer = game.Players.LocalPlayer
local char = localPlayer.Character
local humanoid = char:findFirstChild("Humanoid")
local torso = char:WaitForChild("Torso")

Mouse = localPlayer:GetMouse() --Body Turn Gyro Stuff
game:GetService("UserInputService").MouseIconEnabled = false
BodyGyro = Instance.new("BodyGyro", torso)
BodyGyro.maxTorque = Vector3.new(1,math.huge,1)

Mouse.Move:connect(function()
	print("Moving")
BodyGyro.cframe=Mouse.Hit
end)

Thanks, Off

2 answers

I put this into StarterGui and it worked fine. If it's in Workspace move it somewhere else, LocalScripts do not work in Workspace.

wait(.5)
local localPlayer = game.Players.LocalPlayer
local char = localPlayer.Character
local humanoid = char:findFirstChild("Humanoid")
local torso = char:WaitForChild("Torso")

Mouse = localPlayer:GetMouse() --Body Turn Gyro Stuff
game:GetService("UserInputService").MouseIconEnabled = false
BodyGyro = Instance.new("BodyGyro", torso)
BodyGyro.maxTorque = Vector3.new(1,math.huge,1)

Mouse.Move:connect(function()
    print("Moving")
BodyGyro.cframe=Mouse.Hit
end)

Reasoning: In studio almost all scripts are treated as local scripts and can call instances/functions that regular scripts can't if it's not in studio. If it's a local script in a locally acceptable area such as Backpack or PlayerGui than it's because local scripts load faster than your character so by the time the local script is done your character hasn't loaded properly. To prevent this I added a wait(.5) as a stopped to let everything load properly.

Thumbs up if this helps!

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