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

is not a valid member of Player?

Hello, I was making Hunger bar. I want to do this When you ate something, your Hunger.Value will + Its a Tool.

local Tool = script.Parent
	Tool.Handle.DrinkSound:Play()
	local player = Tool.Parent
	if game.Players.LocalPlayer[player.Name].currHunger.Value <300 then
		game.Players.LocalPlayer[player.Name].currHunger.Value = game.Players.LocalPlayer[player].currHunger.Value +100
		if game.Players.LocalPlayer[player.Name].currHunger.Value >300 then
			game.Players.LocalPlayer[player.Name].currHunger.Value = 300
		end
	end
	if game.Players.LocalPlayer[player.Name].currHunger.Value >300 then
		game.Players.LocalPlayer[player.Name].currHunger.Value = 300
	end

1 comment

0

Can you give the stack it produced?

1 answer

You are accessing player.Name for some reason. game.Players.LocalPlayer is the actual player object, so if currHunger is a child of the player, you can just reference game.Players.LocalPlayer.currHunger. I recommend adding an Instance:WaitForChild() call for currHunger, however.

1 comment

0

not worked

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