So I’m making this script where if I press a key, a part spawns on where I am clicking. But for some reason, it just spawns on a random spot on the map and all the parts spawned there on are located on that random spot.
This is my script
local part = game:GetService("ReplicatedStorage"):WaitForChild("Part")
RemoteEvent.OnServerEvent:Connect(function(player, mouseaim)
local character = player.Character
local mouse = player:GetMouse()
local partClone = part:Clone()
partClone.Parent = workspace
partClone.Position = mouse.Hit.P
end)```
You cannot get the player’s mouse server sided, the server obviously has no concept of input. Is mouseaim the position of the mouse? If so:
local part = game:GetService("ReplicatedStorage"):WaitForChild("Part")
RemoteEvent.OnServerEvent:Connect(function(player, mouseaim)
local character = player.Character
local partClone = part:Clone()
partClone.Position = mouseaim
partClone.Parent = workspace
end)
If not, pass mouseaim as the position of the mouse from the client.