You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I wanna make my car spawn here.
What is the issue?
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.
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
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
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```
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