Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

script not parenting tool to backpack?

local proximity = script.Parent
local tool = game.Workspace.thing

local function giveTool(player, tool)
	local backpack = player:FindFirstChildOfClass("Backpack")
	if backpack then
		tool.Parent = backpack
	end
end


script.Parent.Triggered:Connect(function(player)
	giveTool()
end)


my error

  19:19:00.608  Workspace.pedstall.part2.ProximityPrompt.Script:5: attempt to index nil with 'FindFirstChildOfClass'  -  Server - Script:5

How do i fix this?

btw this is my explorer if you need: https://ibb.co/Zm9Wfws

1 comment

0

Line 13 you forgot to pass the player and tool to the function.

1 answer

[ Hello!, Message from S.H.O. ]


More Simply what you should've had done is Connect the Event to the function Directly


Tool = game.Workspace.Thing

script.Parent.Triggered:Connect(function(player)
	local ClonedTool = Tool:Clone()
	ClonedTool.Parent = player.Backpack
end)

Networks

Roblox


More About S.H.O.

Classified to perfection, Helping Scripter's in need and solving Unanswered Questions


This discussion is preserved as it was. New answers, comments, and votes are closed.