#Im confused..

32 messages · Page 1 of 1 (latest)

upbeat frost
#

This is my script:
local button = script.Parent
local player = game:GetService("Players").LocalPlayer

button.MouseButton1Click:Connect(function()
local currentool = player.Backpack:FindFirstChildWhichIsA('Tool')
currentool.Enabled = true
end)

everytime i click the button it comes out with the error "Players.whyjustwhyf.PlayerGui.ScreenGui.TextButton.LocalScript:6: attempt to index nil with 'Enabled'"
How do i fix it??

vocal elm
#

there is no tool in the players backpack

upbeat frost
#

oh

#

i have a system that gives you tools based off the leaderstats that puts the tool into the players inventory... wouldnt the script see the tool when its put into the players inventory?

upbeat frost
vocal elm
upbeat frost
vocal elm
#

see the thing is

#

when the tool is equipped its no longer in the players backpack

#

when the tool is equipped it goes to the player's character

upbeat frost
#

oh

vocal elm
#

try checking there

upbeat frost
#

ok

#

not to be annoying but, its still popping up with the same error somehow...

vocal elm
#

could you show me the error

upbeat frost
#

thats small.

#

wait

#

Players.whyjustwhyf.PlayerGui.ScreenGui.TextButton.LocalScript:7: attempt to index nil with 'Enabled'

vocal elm
#

whats the uh code now

upbeat frost
# vocal elm whats the uh code now

local button = script.Parent
local player = game:GetService("Players").LocalPlayer

button.MouseButton1Click:Connect(function()
local currentool = player.Character:FindFirstChildWhichIsA('Tool')
local currentool1 = player.Backpack:FindFirstChildWhichIsA('Tool')
currentool.Enabled = true
currentool1.Enabled = true
end)

vocal elm
#

uh not what I meant

#

wait

upbeat frost
#

its kinda like the slap battle system, im tryna make it so you cant use the tool in lobby yet when u spawn in u can use it.

dawn helm
upbeat frost
vocal elm
#
local Button = script.Parent
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

Button.MouseButton1Click:Connect(function()
 local CurrentTool = Player.Backpack:FindFirstChildOfClass("Tool") or Character and Character:FindFirstChildOfClass("Tool")
 if CurrentTool then
  CurrentTool.Enabled = true
 end
end)
dawn helm
#
        currentTool.Enabled = true
    end
    if backpackTool then
        backpackTool.Enabled = true
    end```
#

yeah use that