How to make this script server-sided?

I have a script that causes models to face the direction of my mouse, but only I am able to see it, and no one else.

Is there a way to make the script allow everyone to see it?
(another question, how do I make it only detect my mouse, and no one else’s mouse?)

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()

local Arm = game.Workspace.SpotlightLeft.Holder
local Head = game.Workspace.SpotlightLeft.Light
local Arm2 = game.Workspace.SpotlightRight.Holder
local Head2 = game.Workspace.SpotlightRight.Light

Mouse.Move:Connect(function()
	local MousePosition = Mouse.Hit.Position
	local direction = Vector3.new(MousePosition.X,Arm.WorldPivot.Position.Y,MousePosition.Z)
	Arm:PivotTo(CFrame.new(Arm.WorldPivot.Position, direction))
end)

Mouse.Move:Connect(function()
	local MousePosition = Mouse.Hit.Position
	Head:PivotTo(CFrame.new(Head.WorldPivot.Position, MousePosition))
end)

Mouse.Move:Connect(function()
	local MousePosition = Mouse.Hit.Position
	local direction = Vector3.new(MousePosition.X,Arm.WorldPivot.Position.Y,MousePosition.Z)
	Arm2:PivotTo(CFrame.new(Arm2.WorldPivot.Position, direction))
end)

Mouse.Move:Connect(function()
	local MousePosition = Mouse.Hit.Position
	Head2:PivotTo(CFrame.new(Head2.WorldPivot.Position, MousePosition))
end)
1 Like

You would make a remoteevent and ONLY pass the Mouse and then just copy paste script to the server side and i think you would also need to run a heartbeat on serverside which isn’t good but thats the only way i could think of as of right now

Because you cant get getMouse() from serverSide

you just pass it to serverside by remote event and for the Mouse.Move

you could try RunService

2 Likes