humanoid.HealthChanged:connect(function() local players = game:GetService("Players") end)
I want to assign a variable to the player who makes it lose health.
Step 1: is your code in a localscript? if not, you cannot. Step 2: fixing,
if you are using a normal script, dont use local player:
game.Players[humanoid.Parent.Name]
if you are using a localscript:
game.Players.LocalPlayer