Hello! I have made a system where the player moves their mouse, and their right arm follows, this is in R6. It is working fine so far except I want it to happen on the server as well.
Here is the code:
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local plr = Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local armOffset = char.Torso.CFrame:Inverse() * char["Right Arm"].CFrame
local armWeld = Instance.new("Weld")
armWeld.Part0 = char.Torso
armWeld.Part1 = char["Right Arm"]
armWeld.Parent = char
RunService.Heartbeat:Connect(function()
local cframe = CFrame.new(char.Torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
armWeld.C0 = armOffset * char.Torso.CFrame:toObjectSpace(cframe)
--game.ReplicatedStorage.ArmMovement:FireServer(cframe, mouse.Hit)
end)
As you can see I tried firing a remote event, but that did not work.
In the script that picked up the event, I tried repeating the whole process but it simply wouldn’t work.
Can we see your ServerScript?
Also, keep in mind that in a LocalScript, it’s best practice to wait for things to load.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local plr = Players.LocalPlayer
repeat task.wait() until plr.Character
local char = plr.Character
local mouse = plr:GetMouse()
char:WaitForChild("Torso")
char:WaitForChild("Right Arm")
local armOffset = char.Torso.CFrame:Inverse() * char["Right Arm"].CFrame
...