What do you want to achieve? Keep it simple and clear!
a tool that spawn car when activate
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.
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
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
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
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