Car spawn tool not working

  1. What do you want to achieve? Keep it simple and clear!

a tool that spawn car when activate

  1. What is the issue? Include screenshots / videos if possible!

The tool is not working, there’s no error too so I have no idea why it does not work.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to make it a local script but still doesn’t work

local plr = script.Parent.Parent.Parent
local tool = script.Parent
local isply = workspace:FindFirstChild(plr.Name)
local car = game.ReplicatedStorage.BananaCar
if isply ~= nil then
	local isplayer = isply:FindFirstChild("Humanoid")
	if isplayer ~= nil then
		local pos = isply.Torso.Position
		tool.Activated:Connect(function()
			local clone = car:Clone()
			clone.Position = CFrame.new(pos)
			clone.Parent = isply
		end)
	end
end

You don’t need ‘clone.Parent = isply’

1 Like

I think whats probably happening is that it doesnt find the player when it first loads
maybe change

local isply = workspace:FindFirstChild(plr.Name)
-->
local isply = workspace:WaitForChild(plr.Name)

I think everything else is good

1 Like

Now it is saying "Position is not a valid member of model “BananaCar” How would I fix this error?

ohh I c the problem is that your clone is a model right?
so instead we can do

clone.Position = CFrame.new(pos)
--->
clone:SetPrimaryPartCFrame(isply.Torso.CFrame)
-- i replaced pos so you can probably remove it if ya like or use your cframe
1 Like

Hm, now the error said “Unable to cast Vector3 to CoordinateFrame” How would I fix this and also I would like to know how to make it so it doesn’t spawn directly at the humanoid torso maybe like offset it a bit. I would be very appreciated if you know how. Sorry if I ask to much I am not a scripter so I don’t really know how to do these things.
Maybe I have to change it to CFrame

Oh what line was the error on, also its all good.
I think you can make it spawn next to the player by adding a value to the CFrame

clone:SetPrimaryPartCFrame(CFrame.new(isply.Torso.Position +  Vector3.new(0,1.5,5))

I think this might work It might solve the unable to cast but lemmie know if it errors again.

1 Like

Thanks, It’s working also I tried to make it so that when there already a car that is own by a player and when the player spawn the car again, the original one got destroy and the new one spawn so that the player don’t mass spawn the car. This is what I got, but it is not working, the original car won’t get destroy. Do you know why?

local plr = script.Parent.Parent.Parent
local tool = script.Parent
local isply = workspace:WaitForChild(plr.Name)
local car = game.ReplicatedStorage.BananaCar
if isply ~= nil then
	local isplayer = isply:FindFirstChild("Humanoid")
	if isplayer ~= nil then
		local pos = isply:WaitForChild("Torso").Position
		local folder = Instance.new("Folder")
		folder.Name = "Car"
		folder.Parent = isply
		local Already = isply:WaitForChild("Car"):FindFirstChild("BananaCar")
		tool.Activated:Connect(function()
			if Already == nil then
				local clone = car:Clone()
				clone:SetPrimaryPartCFrame(CFrame.new(isply.Torso.Position +  Vector3.new(10,0,0)))
				clone.Parent = isply:WaitForChild("Car")
			else
				Already:Destroy()
				wait(0.5)
				local clone = car:Clone()
				clone:SetPrimaryPartCFrame(CFrame.new(isply.Torso.Position +  Vector3.new(10,0,0)))
				clone.Parent = isply:WaitForChild("Car")
			end
		end)
	end
end