You should migrate your code onto a client script and then do all the client-based things. After, anything else needed to be done on the server can be done through remote events and functions
On the client:
Handle the tool activating, getting the mouse position, and then calculating the final position. After this, send this calculated position to the server through a remote event
On the Server:
After getting the calculated position from a remote event, move the unit there
local YourRemoteEvent = ReplicatedStorage.YourRemoteEvent
YourRemoteEvent.OnServerEvent:Connect(function(Player, Position)
print('Spawn Noob')
local AI = game.ServerStorage.Spawnables.Marine:Clone()
AI.Parent = game.Workspace
AI:MoveTo(script.Parent.Handle.Position + Vector3.new(Position))
AI:MakeJoints()
end)
Local script:
local plr = game:GetService('Players').LocalPlayer
local mouse = plr:GetMouse()
local YourRemoteEvent = ReplicatedStorage.YourRemoteEvent
script.Parent.Activated:Connect(function()
YourRemoteEvent:FireServer(mouse.Hit.Position)
end)