I am making a script that makes the player gain more XP, Fullness, and Health when they touch a berry, however it only skips to saying "Berry already touched" and does nothing. (FIlteringEnabled is on) Here is the script I am using:
--ServerScript
local HitAlready = false
script.Parent.Touched:connect(function(hit)
if not HitAlready then
HitAlready = true
local Player=game.Players:GetPlayerFromCharacter(hit.Parent)
if Player==nil then return end
Player.Stats.Fullness.Value = Player.Stats.Fullness.Value + script.Parent.Hunger.Value
Player.Stats.XP.Value = Player.Stats.XP.Value + script.Parent.XP.Value
Player.Stats.Health.Value = Player.Stats.Health.Value + script.Parent.Health.Value
script.Parent:Destroy()
else
print("Berry already touched")
end
end)

1 comment
You should try to indent your code to make it more easier for others to read.