Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't this script work?

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

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

2 comments

0

for what? that just gives you the player model

0

Well, there is nothing wrong with that script. There might be something missing however.

This discussion is preserved as it was. New answers, comments, and votes are closed.