#code working in studio but not in game

2 messages · Page 1 of 1 (latest)

fast jasper
#
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService('Players')

local player = Players.LocalPlayer
character = player.CharacterAdded:Wait()
tool = player.Backpack:FindFirstChild("blokic")


if not tool then
    player.Kick("Player is missing the tool")
end

local state = 0

UserInputService.InputBegan:Connect(function(input, gameProcesed)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.Tab then
            if state == 0 then
                character.Humanoid:EquipTool(tool)
                state = 1
            else
                character.Humanoid:UnequipTools()
                state = 0
            end
        end
    end
end)

i dont know, can anyone help?

kindred wadi
#

use :WaitForChild when getting tool