Model won't spawn at position where mouse is

local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local EB = false
local e = false
script.Parent.Equipped:Connect(function()
	e = true
end)
	script.Parent.Unequipped:Connect(function()
	e = false
end)

uis.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.E and EB == false and e == true then
		EB = true
		game.ReplicatedStorage.CarCreate:FireServer()
		local Mouse = player:GetMouse()
		local model = game.ReplicatedStorage.Roadster4
		local backup = model:Clone()
		backup:MoveTo(Mouse.hit.p)
		wait(20)
		EB = false
	end
end)

this is the local script ^^

game.ReplicatedStorage.CarCreate.OnServerEvent:Connect(function()
	local model = game.ReplicatedStorage.Roadster4
	local backup = model:Clone()
	backup:Clone()
	backup.Parent = game.Workspace
	backup:MakeJoints()
	wait(20)
	backup:Destroy()
end)

this is the server script ^^

Everything seems to be working except the car clones at the same spot every time, instead of where the mouse is which is what I’m trying to achieve. This is my first time probably ever experimenting with remote events and client to server stuff so I’m not really sure what the problem is.

You never move the model on the server, you only move a clone of it on the client. This should work:

--Local script
local pos = Vector3.new()--The position of the mouse
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local EB = false
local e = false
script.Parent.Equipped:Connect(function()
	e = true
end)
	script.Parent.Unequipped:Connect(function()
	e = false
end)

uis.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.E and EB == false and e == true then
		EB = true
		game.ReplicatedStorage.CarCreate:FireServer(pos)
		wait(20)
		EB = false
	end
end)

We removed the stuff that moved it on the client, because we have to do it on the server:

--Server Script
game.ReplicatedStorage.CarCreate.OnServerEvent:Connect(function(player,position)
	local model = game.ReplicatedStorage.Roadster4
	local backup = model:Clone()
	backup:MoveTo(position)
	backup.Parent = game.Workspace
	backup:MakeJoints()
	wait(20)
	backup:Destroy()
end)

It still clones it to the exact same spot

Sorry, rushed a bit and made a typo, this should work, as we define what position is.

--Local script
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local EB = false
local e = false
script.Parent.Equipped:Connect(function()
	e = true
end)
	script.Parent.Unequipped:Connect(function()
	e = false
end)

uis.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.E and not EB and e then
		EB = true
		local Mouse = player:GetMouse()
                if Mouse.hit then
		   game.ReplicatedStorage.CarCreate:FireServer(Mouse.hit.p)
                end
		wait(20)
		EB = false
	end
end)
--Server Script
game.ReplicatedStorage.CarCreate.OnServerEvent:Connect(function(player,position)
	local model = game.ReplicatedStorage.Roadster4
	local backup = model:Clone()
	backup:MoveTo(position)
	backup.Parent = game.Workspace
	backup:MakeJoints()
	wait(20)
	backup:Destroy()
end)

If this doesn’t work, I would like to see the file Roadster4

i am not sure why its still not working it still does the exact same thing

Ha, figured it out. :MoveTo only works on objects parented to the workspace.

Change these 2 lines

backup:MoveTo(position)
backup.Parent = game.Workspace

To This:

backup.Parent = game.Workspace
backup:MoveTo(position)

I tried it with a normal model with just a part inside too and its the same thing the model is in replicated storage

Read my reply above. I got a working model:

ToolReproCarThing.rbxl (16.1 KB)

Turns out :MoveTo only works on workspace objects.

Hope this helps.

ok thank u so much it worked i was sort of rushing and didn’t realize that either