So, for context Im trying to make a skateboard you can get off of and get back on/pick it back up when I test it it just doesnt work and this shows up
“Workspace.Myusername.SparkleBoard.LocalScript:3: attempt to index nil with ‘Destroy’”
for context heres the local script i put inside the skateboard:
game:GetService("UserInputService").InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.P then
weld:Destroy()
end
end)
well this is the script inside of the board i did not make it btw its from official roblox
local Board = script.Parent
-- DISGUSTING. NEVER DO THIS.
function nearPlayer()
local p = game.Players:GetPlayers()
for i=1,#p do
if (p[i].Character) then
local t = p[i].Character:FindFirstChild("Torso")
if t then
if (Board.Position - t.Position).magnitude < 20 then
return true
end
end
end
end
return false
end
function sepuku()
if not nearPlayer() then
Board:Remove()
end
end
while true do
wait(30)
sepuku()
end
local players = game:GetService("Players")
local player = players.LocalPlayer
game:GetService("UserInputService").InputBegan:connect(function(key)
if key.KeyCode == Enum.KeyCode.P then
script.Parent = player.BackPack
end
end)