I’m making a skateboard tool and it spawns a skateboard, but it doesn’t spawn if I unequip and equip it again.
Video if needed:
My script:
local canClick = true
local timer = 60
local skateboard
script.Parent.Activated:Connect(function()
if canClick then
canClick = false
skateboard = game.ReplicatedStorage:FindFirstChild("SkateBoard"):Clone()
if skateboard then
print("skateboard spawned!")
skateboard.Mesh.Position = script.Parent.Parent.Torso.Position - Vector3.new(0, 3, 0)
skateboard.Mesh.Orientation = Vector3.new(0, 180, 0)
skateboard.Parent = script.Parent.Parent
local weld = Instance.new("WeldConstraint", skateboard)
weld.Part0 = skateboard.Mesh
weld.Part1 = script.Parent.Parent.Torso
skateboard.Mesh.Anchored = false
timer = 60
while task.wait(0.01) do
timer -= 1
skateboard.Mesh.Orientation = script.Parent.Parent.HumanoidRootPart.Orientation
if timer == 0 or timer < 1 then
break
end
end
end
end
end)
script.Parent.Unequipped:Connect(function()
skateboard:Destroy()
end)
local canClick = true
local skateboard
script.Parent.Activated:Connect(function()
if canClick then
canClick = false
skateboard = game.ReplicatedStorage:FindFirstChild("SkateBoard"):Clone()
if skateboard then
print("skateboard spawned!")
skateboard.Mesh.Position = script.Parent.Parent.Torso.Position - Vector3.new(0, 3, 0)
skateboard.Mesh.Orientation = Vector3.new(0, 180, 0)
skateboard.Parent = script.Parent.Parent
local weld = Instance.new("WeldConstraint", skateboard)
weld.Part0 = skateboard.Mesh
weld.Part1 = script.Parent.Parent.Torso
skateboard.Mesh.Anchored = false
spawn(function()
for i = 1,60 do
wait(1)
if skateboard then
skateboard.Mesh.Orientation = script.Parent.Parent.HumanoidRootPart.Orientation
end
end
end)
end
end
end)
script.Parent.Unequipped:Connect(function()
skateboard:Destroy()
end)