✓ Accepted answer
You can't get a player's Mouse using a Server Script, you should use a LocalScript to get the Player's Mouse
but if you use a LocalScript, it wont replicate to other players so you would need to pass Information from a LocalScript to a Server Script using RemoteEvents
LocalScript (StarterPlayerScripts)
local Player = game:GetService("Players").LocalPlayer
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function()
local Model =
Remote:FireServer(Mouse.Hit.p, Model)
end)
Server Script (ServerScriptService)
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
Remote.OnServerEvent:Connect(function(player, MousePosition, Object)
Object:MoveTo(MousePosition)
end)
1 comment
You cant use Mouse in server script