Hey guys I have a problem that is starting to get me really really frustrated. I've been trying to fix this script for about 1 hour now trying different methodes but It never worked and I have NO IDEA what I'm doing wrong.
Here's the simple script:
local OFFICIALPerksTable = { PowerEngagement = "Very Rare" } local Rarity = Instance.new("StringValue",game.Players.LocalPlayer:WaitForChild("Items").Perks:FindFirstChild(v)) Rarity.Name = "Rarity" local TheStringValueWeWant = v print(v) --Result: PowerEngagement (It's exactly the scring value I need) Rarity.Value = OFFICIALPerksTable.TheStringValueWeWant
The script seems simple right? Supposedly it should read the OFFICIALPerksTable
and return "Very Rare" from "PowerEngagement" (The string that is given).
Instead, it always returns nil. I tried tostring(), tried a for loop, tried changing the table, changing names, locations for 1 h and nothing worked. It would either give me a error saying that the value is nil or will set the Rarity value as "nil"
This is really pissing me off and I don't understand why this is happening. I'm at the limits of my frustration. Some help would really make my day way better without having to deal with this ROBLOX NO SENSE LOGIC. Thanks.
What you're using is a dictionary, not a table. It is important not to get mixed between the two. Also I believe you've forgotten to use an in pairs function.
local OFFICIALPerksTable = { PowerEngagement = "Very Rare" } for key,value in pairs(OFFICIALPerksTable) do local Rarity = Instance.new("StringValue",game.Players.LocalPlayer:WaitForChild("Items").Perks:FindFirstChild(key)) Rarity.Name = "Rarity" local TheStringValueWeWant = key print(key) --Result: PowerEngagement (It's exactly the scring value I need) Rarity.Value = OFFICIALPerksTable.TheStringValueWeWant end
Also in dictionaries when you're doing for in pairs functions instead of the number going first like with tables right here..
table = {"ok", "dont troll please", "i have no life"} for i,v in pairs(table) do print(i) -- would print the number position in the table it's in print(v) -- would print the thing end
It would instead be like this..
dictionary = { mynanabusesme = 20 -- the key would print 20 sosboss = {"crazy facts"} -- the key would be the table so like key[1] would print "crazy facts" } for key, value in pairs(dictionary) do print(key) -- would print out 20 print(value) -- would print out something like table#281ABSC or something like that end
~tantec