Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my 'Brick name teller print' thingy erroring?

I am confused by the Output it is giving me, and why I am getting it, the Output keeps saying 22:01:14.903 - Players.Player1.Backpack.RESET.Reset:23: attempt to index upvalue 'namez' (a function value) 22:01:14.904 - Stack Begin 22:01:14.904 - Script 'Players.Player1.Backpack.RESET.Reset', Line 23 22:01:14.905 - Stack End, but I don't know what to do to fix it, it worked for me before, I'm just now getting this error [note: this happens when you deselect the tool], here is the script;

--Reset HopperBin brought to you by TheeDeathCaster :D
repeat wait() until game.Players.LocalPlayer
local plr = game.Players.LocalPlayer
repeat wait() until plr:GetMouse()
local mouse = plr:GetMouse()
local debounce = true

local namez = function()
if plr and mouse and mouse.Target and not mouse.Target.Locked and debounce then
debounce = false
print(mouse.Target.Name," is the name.")
wait(.1)
debounce = true
end
end

local function Namez()
print(script.Parent.Name.." equipped")
mouse.Button1Down:connect(namez)
end

script.Parent.Selected:connect(Namez)
script.Parent.Deselected:connect(function() namez:disconnect() end) --To keep from reseting even when unselected :)

1 answer

You've accidentally used an , instead of .. in your print function. This should work:

--Reset HopperBin brought to you by TheeDeathCaster :D
repeat wait() until game.Players.LocalPlayer
local plr = game.Players.LocalPlayer
repeat wait() until plr:GetMouse()
local mouse = plr:GetMouse()
local debounce = true

local namez = function()
if plr and mouse and mouse.Target and not mouse.Target.Locked and debounce then
debounce = false
print(mouse.Target.Name.." is the name.")
wait(.1)
debounce = true
end
end

local function Namez()
print(script.Parent.Name.." equipped")
mouse.Button1Down:connect(namez)
end

script.Parent.Selected:connect(Namez)
script.Parent.Deselected:connect(function() namez:disconnect() end) --To keep from reseting even when unselected :)

2 comments

0

It didn't work sadly, I'm still getting the same error. ;-; But thanks for answering man. :)

0

That wasn't the problem: The problem was that I was trying to call Disconnect onto a function and not an event. Also, you can use ',' in prints.

This discussion is preserved as it was. New answers, comments, and votes are closed.