So, I’m trying to make a tool that gets deleted upon equipping if 2 other conditions are met. The conditions being:
The player having another tool called “Bing Helper” in their backpack
A certain number on a random number generating board is the same as the number on the tool
What’s the issue
It just doesn’t work as I expected it to
What have I tried
local ticket = script.Parent
local numBing = game.Workspace["RandomBoards"].BingBoard.SurfaceGui.TextLabel
local numTicket = script.Parent.Handle.SurfaceGui.TextLabel
ticket.Equipped:Connect(function(plr)
wait(0.2)
if plr:FindFirstChild("Backpack"):FindFirstChild("Bing Helper") and numTicket.Text == numBing.Text then
ticket:Destroy()
else
return
end
end)
From this it just gives me this error in the output:
Workspace.Lost_Cabrexada.Number Ticket.Script:9: attempt to index nil with 'FindFirstChild'
local ticket = script.Parent
local numBing = game.Workspace["RandomBoards"].BingBoard.SurfaceGui.TextLabel
local numTicket = script.Parent.Handle.SurfaceGui.TextLabel
ticket.Equipped:Connect(function(Mouse)
wait(0.2)
local Player = game.Players:GetPlayerFromCharacter(ticket.Parent)
if Player then else return end
if Player.Backpack:FindFirstChild("Bing Helper") and numTicket.Text == numBing.Text then
ticket:Destroy()
end
end)
instead of getting the players from the parameter wich is actually a mouse. you should get the parent of the tool. as this is always the players character when equipped.