I'm trying to get the user to place parts where ever the mouse is positioned. I'm using remote functions. I have a localscript in the tool the user uses. Then a script in serverscriptservice. Script in SSS
function placebrick() local part Instance.new("Part", game.Workspace) end game.ReplicatedStorage.Events.RemoteFunction.OnServerInvoke = placebrick
Localscript in tool
script.Parent.Activated:Connect(function() game.ReplicatedStorage.Events.RemoteFunction:InvokeServer() end)
Help please?
You cannot access the mouse directly from the server. Instead, you need to send it the data from the client across your RemoteFunction:
local mouse = game.Players.LocalPlayer:GetMouse() script.Parent.Activated:Connect(function() game.ReplicatedStorage.Events.RemoteFunction:InvokeServer(mouse.Hit.p) -- mouse position end)
In the server:
function placebrick(player, mousePosition) local part = Instance.new("Part", game.Workspace) part.Position = mousePosition end game.ReplicatedStorage.Events.RemoteFunction.OnServerInvoke = placebrick
You have to get the mouse position in the LocalScript and send it as a parameter of the RemoteFunction, then get it on the server and set the part position to it.