Ad
Log in to vote
0

script not parenting tool to backpack?

Asked by 16 days ago
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

0
Line 13 you forgot to pass the player and tool to the function. Xientra 17 — 16d

1 answer

Log in to vote
0
Answered by 16 days ago

[ 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


Ad

Answer this question