Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why is my health script saying that the variable is a function? . _ .

you read the title; at line 21 it's referencing Health as a function???

local Player = game.Players.LocalPlayer
local Healths = Player.Health

function Change()
	local CurrentHealth = Player.Health.Value
	
	if CurrentHealth > 0 then
		print(CurrentHealth)
	else
		
		for i = 1,0,-.01 do
			script.Parent.BackgroundTransparency = i
			wait()
			
		end
	end
end

script.Parent.TextButton.Activated:Connect(function()
	script.Parent.Visible = false
	Health.Value == 100
	
end)

Health.Changed:Connect(function()
	if Health.Value == 0 then
		Change()
		
	end
end)

1 comment

0

isn’t the variable supposed to be Healths because Health is unknown

1 answer

✓ Accepted answer

"==" indicates an equality comparison. On line 21, this simply evaluates to true/false. You are looking for the assignment operator "=," to set the health to 100. Also, based on your code, "Health.Value" should be replaced with "Healths.Value" since that is the name of the variable you initialized above.

This discussion is preserved as it was. New answers, comments, and votes are closed.