Help, I can not understand what the problem is here.
local uis = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("toolEvent") -- <
local plr = game.Players.LocalPlayer
local PressE = game.Workspace.tools.Key.Handle.Center.BillboardGui
attempt to index local 'char' (a nil value)
function search()
local tools = workspace:WaitForChild("tools"):GetChildren()
local min = nil
local tool = nil
for i = 1, #tools do
local handle = tools[i]:FindFirstChild("Handle")
if handle then
local mag = (char.HumanoidRootPart.Position-handle.Position).magnitude
if min == nil or mag < min then
min = mag
tool = tools[i]
end
end
end
if min then
if min < 5 then
return tool
end
end
end
uis.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType.Name == "Keyboard" and gameProcessed == false then
if input.KeyCode.Name == "E" then
local tool = search()
if tool then
event:FireServer(tool)
PressE.Enabled = false
end
end
end
end)
while wait(1) do
local tool = search()
if tool then
PressE.Enabled = true
else
PressE.Enabled = false
end
end
Problem:
22:44:30.713 - Players.BITCr8ator.PlayerScripts.LocalScript:18: attempt to index local 'char' (a nil value) 22:44:30.738 - Stack Begin 22:44:30.738 - Script 'Players.BITCr8ator.PlayerScripts.LocalScript', Line 18 - global search 22:44:30.740 - Script 'Players.BITCr8ator.PlayerScripts.LocalScript', Line 46 22:44:30.741 - Stack End

2 comments
are you sure this is the right script?
Line 17, you're using the variable char but you never defined it prior.