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

Why won't this script work?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
for _,food in pairs(game.Workspace:WaitForChild("Holder"):GetChildren()) do
    food.Touched:connect(function(hit)
        local other = hit.Parent:findFirstChild("Food")
        local player = hit.Parent:findFirstChild("Humanoid")

        if other ~= nil then
            other:Remove()
        elseif player ~= nil then
            local plr = player.Parent
            food:Destroy()

            local getValue = game.Players[plr.Name]:WaitForChild("FoodAmount")

            getValue.Value = getValue.Value + 1
        end
    end)
end

1 answer

Log in to vote
0
Answered by 8 years ago

Check if there is anything missing. Also, try using game.Players:getPlayerFromCharacter(plr)

0
for what? that just gives you the player model thehybrid576 294 — 8y
0
Well, there is nothing wrong with that script. There might be something missing however. konlon15 32 — 8y
Ad

Answer this question