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

"chicken is not a valid member of StarterPack" error in module script?

Asked by
Vid_eo 126
6 years ago

I have a module script in ReplicatedStorage and a script in a tool. In the module script I have a function w. 3 parameters, the values of which are set in the script. For some reason, I used one of the parameters in the module script, and it errored, saying "chicken is not a valid member of StarterPack" in the module script.

MODULE SCRIPT:

local module = {}

local player = game.Players.LocalPlayer
local leaderstats = player.leaderstats
module.giveChickenEaten = function(chicken, chickenIntValue, biteAmount)
    print("Calculating chicken eaten...")
    leaderstats["Chicken Eaten"].Value = leaderstats["Chicken Eaten"].Value + game.StarterPack.chicken.chickenIntValue.Value --chikcen is not a valid member of StarterPack
    biteAmount.Value = biteAmount.Value - 1
    if biteAmount.Value == 0 then
        chicken:Destroy()
    end
end

return module

SCRIPT:

local module1 = require(game.ReplicatedStorage.ModuleScript) --where the module script is activated
    module1.giveChickenEaten(script.Parent, script.Parent.coldFriedChickenValue.Value, script.Parent.biteAmount.Value)

--(this is activated inside a function)

Thanks!

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

Put this after line 5:

game.StarterPack:WaitForChild("chicken")

Or, maybe there is nothing called "chicken" in the starterpack. Are you sure it's the starterpack and not the specific startergear of the player?

0
There's nothing called chicken, it was just the parameter Vid_eo 126 — 6y
0
If there is nothing called "chicken" in the StarterPack, then you can't index it. If it's the parameter, it acts like a variable. Does removing "game.StarterPack" in line 7 help? UgOsMiLy 1074 — 6y
0
Thanks! I just had to remove all the ".value" parts. The biteAmount part still won't work, though (I deleted the .Value). Vid_eo 126 — 6y
Ad

Answer this question