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 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
01for _,food in pairs(game.Workspace:WaitForChild("Holder"):GetChildren()) do
02    food.Touched:connect(function(hit)
03        local other = hit.Parent:findFirstChild("Food")
04        local player = hit.Parent:findFirstChild("Humanoid")
05 
06        if other ~= nil then
07            other:Remove()
08        elseif player ~= nil then
09            local plr = player.Parent
10            food:Destroy()
11 
12            local getValue = game.Players[plr.Name]:WaitForChild("FoodAmount")
13 
14            getValue.Value = getValue.Value + 1
15        end
16    end)
17end

1 answer

Log in to vote
0
Answered by 9 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 — 9y
0
Well, there is nothing wrong with that script. There might be something missing however. konlon15 32 — 9y
Ad

Answer this question