Why its not working?

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)

and the other script is complicated

it means weld does not exist

where did you define weld

I dont know should I send the script?

yes you should send the whole script

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

no i meant the script where you destroy the weld, the whole one, not just the snippet

that is the whole script though

then how the heck did you think it could work if the weld isnt defined

:Remove() is deprecated too, so use :Destroy()

dude what does a weld even mean

bro what the actual ___

then what is your goal

1 Like

To have the player press P then pick up the skateboard

and the skateboard is a tool right?

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)

its not i dont think its a tool

can you send the whole file then please

or send a screenshot of your hierarchy

okok.obj (90.2 KB)
sorry my mouse just broke i dont know whats going on

i had to borrow another one
let me know if it works

124125886 heres the link if you want that