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

is not a valid member of Player?

Asked by 6 years ago

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
0
Can you give the stack it produced? sweetkid01 176 — 6y

1 answer

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

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.

0
not worked FrezeTagger 75 — 6y
Ad

Answer this question