-
What do you want to achieve?
I basically want to refer to the attributes in the image (Carni, herbi and omnivore) for a hunger system in my animal survival game. The eatables have bool values (Eatable → true/false) which works perfectly fine if u tick the box, it’s eatable and if not then it’s not. Now I want it, if you tick the box carnivore, the bool of the eatable thing “Grass” becomes false, so that the animal cannot eat it. If herbivore, the bool eatable for “Meat” becomes false. And for omnivore, both values are true for grass and meat. -
What is the issue?
I kinda don’t know how I should comprehend it in a script so it actually works. -
What solutions have you tried so far?
looked on the dev hub but was not able to find anything since this is a specific case.
That’s some code I tried but with no effect (I am not surprised)
local carnivore = false
local herbivore = false
local omnivore = false
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local meat = game.Workspace.Meat.Eatable
local grass = game.workspace.Grass.Eatable
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(character)
if humanoid.Carnivore == true then
meat = true and grass == false
elseif humanoid.Herbivore == true then
meat = false and grass == true
elseif humanoid.Omnivore == true then
meat = true and grass == true
end
end)
end)
The attributes, stored in the humanoid of the animal model: