Hi, I am currently creating a Hunger System. I want there to be some sort of effects once the players ate the food
tool = script.Parent
players = tool.Parent
eated = false
canvalue = 10
local Plr = game:GetService("Players").LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")
playerEat = game:GetService("ReplicatedStorage").Eat
game.Players.PlayerAdded:Connect(function(player)
players = player
end)
tool.Activated:Connect(function()
playerEat:Fire(players,canvalue)
Hum.WalkSpeed = 2
eated = true
if eated == true then
script.Parent:Destroy()
end
end)
As you can see here, I am trying to make it so If the tool is activated then the local player character speed needs to be lowered. But since It is a script, It gave me this error :
Workspace.Can.Script:6: attempt to index nil with 'Character'
I am sorry If this is not clear enough but if it isn’t please feel free to ask me to reword this question in a way where you could understand it