Spawning a model in front of a player

Hi there!
I’m making a GUI spawn button to spawn a bike (Model)
The script works but the only thing I need is that the bike will spawn in front of the player who clicks the GUI button. (The script is a ServerScript inside the TextButton)
Can I get some help with the positioning of the model (In front of the Player)
Here is my current script:

local enabled = false
local Player = game.Players.LocalPlayer



	script.Parent.MouseButton1Click:Connect(function(GetCar)
	if enabled == false then
		enabled = true
		local Mod = game.ServerStorage['Bicycle']
		local clone = Mod:clone()
		clone.Parent = workspace
		clone.Name = "Bicycle"
		
		wait(5)
		enabled = false
				

	end

end)



Btw: Did I made the variable ‘Player’ correctly? (Just to check)

1 Like

You could do something like…

local targetPosition = Player.Character.HumanoidRootPart.CFrame*CFrame.new(0, 0, -4)
clone:MoveTo(targetPosition)
1 Like

You could also just reference the Character CFrame’s LookVector property, that way it’ll always spawn in front of the player:

local enabled = false
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart"

	script.Parent.MouseButton1Click:Connect(function(GetCar)
	if enabled == false then
		enabled = true
		local Mod = game.ServerStorage['Bicycle']
		local clone = Mod:clone()
		clone.Parent = workspace
		clone.Name = "Bicycle"
        clone:MoveTo(HRP.CFrame.LookVector * 5)
		wait(5)
		enabled = false	
	end
end)

If this is on a LocalScript, then yes

Another way you can do it is by setting the Model’s PrimaryPartCFrame and moving it that way, excluding collisions as long as the Model itself has a PrimaryPart

dm me in discord: NvTheDeveloper#8022