Hello, I was trying to do a weapon that can equip and activate another tool when right-clicking. The script works for me on studio but when I try it in the real game, it equips the tool but doesnt do anything. Here's my script:
local v = game.Players.LocalPlayer
local vm = v:GetMouse()
local w = script.Parent.Parent:WaitForChild("Bomb")
local t = script.Parent
local used = false
t.Equipped:Connect(function(Mouse)
Mouse.Button2Down:connect(function()
if not used then
used = true
t.AutoEquip.Disabled = true
v.Character.Humanoid:EquipTool(w)
wait(0.1)
w:Activate()
game.Workspace:WaitForChild("TimeBomb"..v.Name)
t.AutoEquip.Disabled = false
wait(5)
used = false
end
end)
end)
Everything is in the explorer place it should be. In the real game console, it returns: Attempt to index a nil value
Thanks

5 comments
Please put the script in a codeblock.
Also what line is it printing nil value for also?
sorry... i am new... how do I put the script in a codeblock?
Put four spaces or a tab before each line. I had trouble with that at first too.
Confirm that "TimeBomb" with the players name is in workspace at the time it prints Nil