Why is Position or Cframe working?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I wanna make my car spawn here.

  2. What is the issue? image

  3. What solutions have you tried so far? Youtube

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

script.Parent.MouseButton1Click:Connect(function()
	wait(1)
	 local player = game.Players.LocalPlayer
	local button = script.Parent
	local debounce = false

local function helpme()
		if not debounce then
local CarAwardUi = player.PlayerGui.CarAward.TextButton
	
			debounce = true
			HumanoidRootPart = player.Character.HumanoidRootPart
			LowerTorso = player.Character.LowerTorso
			LowerTorso.CFrame = game.Workspace.CarSpawnPlayer.CFrame -- change the "part" to where ever you want player  to go
			local car = game.Workspace.Car
			car:Clone()
			car.Parent = game.Workspace
			
		local SpawnCar  = game.Workspace.CarSpawn
			car.Position = HumanoidRootPart.CFrame
			if CarAwardUi.Visible == true then
				CarAwardUi.Visible = false
			end
		end
	end
	button.MouseButton1Click:connect(helpme)

	while true do wait()
		debounce = false
	end
	
	
	
	

end)

If car is a model, you need to do :SetPrimaryPartCFrame() and make sure you defined a primary part. Models don’t actually have a CFrame or Position property.

3 Likes

Use :SetPrimaryPartCFrame()
btw in order for this to work you need to make sure your model has a primarypart

script.Parent.MouseButton1Click:Connect(function()
	wait(1)
	 local player = game.Players.LocalPlayer
	local button = script.Parent
	local debounce = false

local function helpme()
		if not debounce then
local CarAwardUi = player.PlayerGui.CarAward.TextButton
	
			debounce = true
			HumanoidRootPart = player.Character.HumanoidRootPart
			LowerTorso = player.Character.LowerTorso
			LowerTorso.CFrame = game.Workspace.CarSpawnPlayer.CFrame -- change the "part" to where ever you want player  to go
			local car = game.Workspace.Car
			car:Clone()
			car.Parent = game.Workspace
			
		local SpawnCar  = game.Workspace.CarSpawn
			car:SetPrimaryPartCFrame(HumanoidRootPart.CFrame)  --//Changed to car:SetPrimaryPartCFrame()
			if CarAwardUi.Visible == true then
				CarAwardUi.Visible = false
			end
		end
	end
	button.MouseButton1Click:connect(helpme)

	while true do wait()
		debounce = false
	end
1 Like

Your script is working but I want the car to clone then spawn in front of the player.

script worked that another person said but I want the car to clone and spawn in front of me.

	wait(1)
	 local player = game.Players.LocalPlayer
	local button = script.Parent
	local debounce = false

local function helpme()
		if not debounce then
local CarAwardUi = player.PlayerGui.CarAward.TextButton
	
			debounce = true
			HumanoidRootPart = player.Character.HumanoidRootPart
			LowerTorso = player.Character.LowerTorso
			LowerTorso.CFrame = game.Workspace.CarSpawnPlayer.CFrame -- change the "part" to where ever you want player  to go
			local car = game.Workspace.Car
			car:Clone()
			car.Parent = game.Workspace
			
		local SpawnCar  = game.Workspace.CarSpawn
			car:SetPrimaryPartCFrame(HumanoidRootPart.CFrame)  --//Changed to car:SetPrimaryPartCFrame()
			if CarAwardUi.Visible == true then
				CarAwardUi.Visible = false
			end
		end
	end
	button.MouseButton1Click:connect(helpme)

	while true do wait()
		debounce = false
	end```

You could just create a CFrame.new() value, then multiply where the HumanoidRootPart’s LookVector is facing which would make the car spawn in front of the Player

			car:SetPrimaryPartCFrame(CFrame.new(HumanoidRootPart.Position + HumanoidRootPart.CFrame.LookVector * 15))

Can you put it into the whole script It’s a bit confusing for me.

	wait(1)
	 local player = game.Players.LocalPlayer
	local button = script.Parent
	local debounce = false

local function helpme()
		if not debounce then
local CarAwardUi = player.PlayerGui.CarAward.TextButton
	
			debounce = true
			HumanoidRootPart = player.Character.HumanoidRootPart
			LowerTorso = player.Character.LowerTorso
			LowerTorso.CFrame = game.Workspace.CarSpawnPlayer.CFrame -- change the "part" to where ever you want player  to go
			local car = game.Workspace.Car
			car:Clone()
			car.Parent = game.Workspace
			
		local SpawnCar  = game.Workspace.CarSpawn
			car.Position = HumanoidRootPart.CFrame
			if CarAwardUi.Visible == true then
				CarAwardUi.Visible = false
			end
		end
	end
	button.MouseButton1Click:connect(helpme)

	while true do wait()
		debounce = false
	end```

Use a remote event because the car wont work on spawn since local script

What

No need for a RemoteEvent, the car would be able to spawn but it’d only be locally for the client

@Extnent All you’re just really doing is replacing that 1 line when you call :SetPrimaryPartCFrame() with my line :slightly_smiling_face:

Thank you so much! I’ve been trying to find this out for a while.

I know I didn’t know if they wanted it to happen on the server lol

One more problem how can I make it spawn like 10 studs above the ground?

Adding onto what I previously said, we could set where our HumanoidRootPart’s Position would be by adding an offset position by adding the Y axis by 10

			car:SetPrimaryPartCFrame(CFrame.new((HumanoidRootPart.Position + Vector3.new(0, 10, 0)) + HumanoidRootPart.CFrame.LookVector * 15))

Could you try this? I believe it should work, but try it to make sure

1 Like

It works thanks! Imma have to do a few changes but It works!

You know you can just multiply CFrames, for example HumanoidRootPart.CFrame*CFrame.new(10,0,0). It’s that simple.

1 Like

Seriously? CFrames never fail to confuse me, funni

@Extnent Do make sure to mark the post as a solution if it helps so that other people are aware about this being solved! :slightly_smiling_face: