Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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

Log in to vote
-1
Answered by 9 years ago

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 :)

0
It didn't work sadly, I'm still getting the same error. ;-; But thanks for answering man. :) TheeDeathCaster 2368 — 9y
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. TheeDeathCaster 2368 — 6y
Ad

Answer this question