Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Vehicle spawning next to player?

I am working on a vehicle game and im making a car spawner. I have a gui and the cars spawn. Though they only spawn at the location they are in. How can I make it spawn next to the player? Here is my code.

function Click() 
game.Lighting["F8"]:Clone().Parent = game.Workspace


end 

script.Parent.MouseButton1Down:connect(Click) 

The F8 is the car.

1 answer

✓ Accepted answer

You did not define there position using


Vector3.new ()

To position this try using this code make sure its a local script

function Click() 
local Player = game.Players.LocalPlayer
game.Lighting["F8"]:Clone().Parent = game.Workspace
game.Lighting["F8"].Position = Player.Character.Head.Position + Vector3.new(0, 0, 5)
end

script.Parent.MouseButton1Down:connect(Click) 


Or If The Thing Is a model use the code below

function Click() 
local Player = game.Players.LocalPlayer
game.Lighting["F8"]:Clone().Parent = game.Workspace
game.Lighting["F8"]:MoveTo(Player.Character.Head.Position + Vector3.new(0, 0, 5))

end

script.Parent.MouseButton1Down:connect(Click) 




5 comments

0

Still spawns in the original place. https://gyazo.com/00fbf7654b1cec71ac38bdc5e5287c0c

0

You need to assign the local clone to a variable and then change the position of that clone. I've posted the script in this pastebin. https://pastebin.com/GFMtGCwc

0

Also this won't work in FE.

0

It works fine in studio but in the real game only 1/4 of the cars work, the other cars freeze in air and when I sit in it it shows a speed bar at the bottem and I cant move the car.

0

I figured it out.

This discussion is preserved as it was. New answers, comments, and votes are closed.