I am doing my own health system for my game and I am having trouble with decrasing a player's HP. This script is in the part that you need to touch to decrease HP.
debounce = false function onTouched(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then if not debounce then if script.Parent.Name == "Ball" then debounce = true local plr = game.Players:GetPlayerFromCharacter(hit.Parent) plr.leaderstats.HP.Value = plr.leaderstats.HP.Value-1 wait(5) debounce = false end end end end script.Parent.Touched:Connect(onTouched)
It works in roblox studio but not in the real game. Everything is in the place it should be and have these names. In the game, it returns: "leaderstats is not a valid member of player" (line 9)
Thanks
Hi Vewixx,
Thanks,
Best regards,
~~ KingLoneCat