So… I have this local script located in StarterPlayerScripts and in this script it will make the player follow the camera. However, when I tested it, let’s say player 1 (myself, player itself) can see the effects of the script, but player 2 doesn’t see the effects from player 1. Keep in mind that player 1 is (the half blue and half red sweater) and player 2 is the bacon boi.
My plan to solve this was to have when the player joins the game, a script run that makes a remote event in ReplicatedStorage fire( Because someone told me to use remote events). Sadly it has errors. I want to know where did I go so wrong.
The script in ServerScriptService ( I’m using a print to see if it’s working or not. Sadly it didn’t print)
local event = game.ReplicatedStorage.Events.CharacterfollowMouse
event.OnClientEvent:Connect(function()
print("hmmmm yes progress")
end)
The local script in StarterPlayerScripts(this script should fire the remote event when the player joins. Since I’m new at scripting my knowledge on how to fire remote events it using a local script)
local event = game.ReplicatedStorage.Events.CharacterfollowMouse
game.Players.PlayerAdded:Connect(function(player)
event:FireClient()
end)
The remote event in ReplicatedStorage
The Local script that makes the upper torso of the player follow the mouse
local plr = game.Players.LocalPlayer
local neckC0 = CFrame.new(0, 0.8, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local waistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local function onUpdate(dt)
if plr.Character ~= nil then
local camera = workspace.CurrentCamera;
local body = plr.Character.HumanoidRootPart
if plr.Character.Head.Neck ~= nil then --neck joint is not broken
if plr.Character.UpperTorso:FindFirstChild("Waist") ~= nil then
local neck = plr.Character.Head.Neck;
local waist = plr.Character.UpperTorso.Waist;
local theta = math.asin(camera.CFrame.LookVector.y)
local camera_angle = math.atan2(camera.CFrame.LookVector.X, camera.CFrame.LookVector.Z)
local body_angle = math.atan2(body.CFrame.LookVector.X, body.CFrame.LookVector.Z)
local theta2 = (camera_angle-body_angle)%(2*math.pi)
if theta2 > math.pi/2 and theta2 < math.pi*1.5 then
theta2 = math.pi-theta2
end
waist.C0 = waistC0 * CFrame.Angles(theta*1, 0, 0);
end
end
end
end
game:GetService("RunService").RenderStepped:Connect(onUpdate);
I want to know where did I go so wrong and how to fix it. Oh great devloper lords please help me ;-;