#Why does nothing print>?

1 messages · Page 1 of 1 (latest)

plush hare
#
local ToolTable = {
    ["Sword"] = {
        Damage = 10,
        Range = 5
    },
    ["Hammer"] = {
        Damage = 20,
        Range = 2
    }
}

local Sword = game:GetService("StarterPack"):WaitForChild("Sword")
local Hammer = game:GetService("StarterPack"):WaitForChild("Hammer")

Sword.Equipped:Connect(function()
    for Info, value in pairs(ToolTable["Sword"]) do
        print(Info,value)
    end
end)

exotic sparrow
#

Oh nvm

#

It's just that i'm used to i,v

plush hare
#

doesn't print anything

#

this is in a server script

#

im trynna see if it works in a local rn

glacial abyss
#

Maybe do ipairs

#

Ngl I have no idea what's the difference between them

normal wadi
#

I think it is a problem with the way you are trying to access the sword object

#

things in starter pack gets replicated to the player's backpack on game start

exotic sparrow
glacial abyss
#

Also try printing something after you equip the sword

#

That will tell you what's wrong

normal wadi
#

so to get the actual sword that is in the player's inventory ou need to go through the player backpack

glacial abyss
#

Yeah so try printing

plush hare
#

found out the issue

normal wadi
#

similar difference between starterGui and playergui

plush hare
#

had to put it into startercharacter

#
local ToolTable = {
    ["Sword"] = {
        Damage = 10,
        Range = 5
    },
    ["Hammer"] = {
        Damage = 20,
        Range = 2
    }
}
local player = game.Players.LocalPlayer
local Sword = player.Backpack:WaitForChild("Sword")
local Hammer = player.Backpack:WaitForChild("Hammer") 

Sword.Equipped:Connect(function()
    for Info, value in pairs(ToolTable["Sword"]) do
    print(Info,value)
    end
end)
#

and changed the scripot

#

to this

#

Thank you all for trynna help, sorry if I wasted your time.

exotic cape
#

you could abstract this a bit to save a lot of repetition

#

like using childadded on the players backpack to try to connect an equipped listener to the tool, then seeing if it has data in the table and accessing it