local GetPetData = {}
function GetPetData.ReturnData(Pet)
local data = {
PetName = nil,
CoinsMutliplier = nil,
GemsMultiplier = nil
}
print(Pet)
local PetDataBase = {
["Red"] = {
PetName = "Red",
CoinsMultiplier = 1.2,
GemsMultiplier = 1.2
},
["Green"] = {
PetName = "Green",
CoinsMutliplier = 1.4,
GemsMultiplier = 1.4
},
["Blue"] = {
PetName = "Blue",
CoinsMultiplier = 1.6,
GemsMultiplier = 1.6
},
}
data.PetName = PetDataBase[Pet].PetName.Value
data.CoinsMutliplier = PetDataBase[Pet].CoinsMultiplier
data.GemsMultiplier = PetDataBase[Pet].GemsMultiplier
return(data)
end
return GetPetData
#Help with tables
18 messages · Page 1 of 1 (latest)
so if I get this right, you want to be able to get the full table by sending a function a the name (as a string)?
yes
function GetPetData.ReturnData(Pet)<-- the pet here comes through as a name such as Red, Blue or Green
if so, then just do
--all I changed is fixing the discord symbols so it highlights the lua syntax. Rest is still the same
local GetPetData = {}
local PetDataBase = {
["Red"] = {
PetName = "Red",
CoinsMultiplier = 1.2,
GemsMultiplier = 1.2
},
["Green"] = {
PetName = "Green",
CoinsMutliplier = 1.4,
GemsMultiplier = 1.4
},
["Blue"] = {
PetName = "Blue",
CoinsMultiplier = 1.6,
GemsMultiplier = 1.6
},
}
function GetPetData.ReturnData(PetName:string):{}?
return PetDataBase[PetName]
end
return GetPetData
maybe fix some capitalization issues if I accidentally missed a cap or something similar
worksp erfectly thanks
no problem
you can automatize the pet name tho
i got a problem now when red is selected it works perfectly but when green or blue is selected on this line petPad:WaitForChild("CoinsMultiplier").Value = data.CoinsMultiplier i get value of type nil cannot be converted to a number so its giving nil
i added print(data.PetName) just above and it prints green so its just the values
nevermind it was a spelling error
nevermind it wasnt, spelling error didnt fix anything
oh my nevermind it was anotherr one which actually did fix it
i appolagise