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

Spawning vehicle in a certain spot?

I have been trying to spawn a vehicle. It works, but when I try to get it to spawn in a certain spot like a spawner part, it doesn't seem to comply.

This is code

script.Parent.MouseButton1Click:connect(function(GetCar)
		Mod = game.ServerStorage["Dodge Charger"]
		local clone = Mod:clone()
		clone.Parent = workspace
		clone.CFrame = script.Parent.Parent.Parent.Parent.Parent.SpawnPart.CFrame
		clone:MakeJoints()
		script.Parent.Parent.Parent:Destroy()
end)

Fyi, it is a GUI textbutton.

2 answers

###Your script is a local script. ServerStorage cannot be accessed by the client. Place the model in ReplicatedStorage so the client can access it.

local sP = script.Parent.Parent
local sP2 = sP.Parent.Parent

script.Parent.MouseButton1Click:Connect(function() -- :connect is deprecated, switch to :Connect
        Mod = game:GetService("ReplicatedStorage")["Dodge Charger"]
        local clone = Mod:Clone() -- :clone is deprecated, switch to :Clone
        clone:SetPrimaryPartCFrame(sP2.SpawnPart.CFrame) -- make sure to set a primary part!
        clone.Parent = workspace
        clone:MakeJoints()
        sP.Parent:Destroy()
end)

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