#CollectionService:GetTagged() doesnt work after a tool is cloned

8 messages · Page 1 of 1 (latest)

nova blaze
#

So i tried adding food and hunger system to my game and the issue is that the player buys the food by clicking gui button and the food/tool clones but if a player activates the tool it should destroy itself and give the player some value but it doesnt do that even if the cloned tool has a tag. How can i fix this? Here is the script: (its not all of it) ```lua
coroutine.wrap(function()
while task.wait(2.5) do
if Hunger.Value > 0 then
Hunger.Value -= 1

        if Hunger.Value == 0 then
            repeat
                humanoid:TakeDamage(10)
                task.wait(1)
            until humanoid.Health == 0 or Hunger.Value > 0
            
        end
    end
end

end)()

for tools, tool in pairs(CollectionService:GetTagged("Food")) do
tool.Activated:Connect(function()
local newVal = math.clamp(Hunger.Value + tool.Gain.Value, 0, 100)

    tool.Enabled = false
    tool:Destroy()

    Hunger.Value = newVal
end)

end

Hunger:GetPropertyChangedSignal("Value"):Connect(Update)``` also hunger is an int value inside the player and some guy told me to make the tool break after its activated inside the tool script every tool has but didnt tell me how I could even get local player inside a server script.

nova marsh
#

I don't remember saying that at all

#

I'll just write it for you...

#

This is all the code you need. One script inside of every tool

nova blaze
nova marsh
#

I'm not obligated to help you, especially when you're treading waters you're not ready for. I have judged you in the most literal sense. I have tried to help you 3 times now, and yet I'm given attitude

#

You've seen what the solution looks like. You can get yourself the rest of the way