Model spawns in wrong area?

To spawn the model infront of the person using the tool

You forgot to set the clone’s primary part. clone.PrimaryPart = PrimePart (EDIT: make sure to change the name of one of the parts in the model to “PrimePart” or a name of ur choosing)

1 Like

Instead, why not just the HumanoidRootPart CFrame, and use LookVector to spawn it in front of the player?

When you make a clone, the PrimaryPart stays.

1 Like

Ive set the primary part for the model i want to spawn.
I dont know how to use LookVector. As i said im a beginner scripter

Here is your updated code:

local cybertruck = game.ServerStorage.ModelSpawnerFolder.Cybertruck
local button = script.Parent
local gui = script.Parent.Parent.Parent.Parent
local targetpart = game.ServerStorage.DevTools.SpawnerTool.TargetPart
local cooldown = false
button.MouseButton1Click:Connect(function()
    if cooldown == false then
	cooldown = true
	local clone = game.ServerStorage.ModelSpawnerFolder.Cybertruck:Clone()
	local cframe = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame -- Change this, this is gross
	clone:SetPrimaryPartCFrame(cframe + cframe.LookVector * 10)
	clone.Parent = game.Workspace
	button.Text = "Cooldown for 2 seconds.."
	wait(2)
	cooldown  = false
	 button.Text = "CyberTruck"
   end
end)
1 Like

It doesnt work for some reason i click the button but it doesnt do anything doesnt even say cooldown

What is the output saying? (30)

1 Like

Nothing somehow im clicking the button but nothing is happening

Do some printing between lines. What is the last to print?

Wait i found the problem i deleted the target part and the varible is still there so it stopped there trying to find the target part

1 Like

Ok now that the script is fixed i click the button gives me this error
13:24:47.402 Players.spydercam500.PlayerGui.SpawnToolGui.MainFrame.ScrollingFrame.CybertruckButton.Script:9: attempt to index nil with ‘Character’ - Server - Script:9
@iGottic

I just realized you’re doing the UI on the server side of the code. At this point, it’s beyond proper fixing, only random patches.

You can work around it though with this code:

local cybertruck = game.ServerStorage.ModelSpawnerFolder.Cybertruck
local button = script.Parent
local gui = script.Parent.Parent.Parent.Parent
local targetpart = game.ServerStorage.DevTools.SpawnerTool.TargetPart
local cooldown = false
button.MouseButton1Click:Connect(function()
    if cooldown == false then
	cooldown = true
	local clone = game.ServerStorage.ModelSpawnerFolder.Cybertruck:Clone()
	local cframe = gui:FindFirstAncestorOfClass("Player").Character.HumanoidRootPart.CFrame -- Change this, this is gross
	clone:SetPrimaryPartCFrame(cframe + cframe.LookVector * 10)
	clone.Parent = game.Workspace
	button.Text = "Cooldown for 2 seconds.."
	wait(2)
	cooldown  = false
	 button.Text = "CyberTruck"
   end
end)

:MoveTo() uses Vector3 to move the model

but the models needs a PrimaryPart