Attempt to index number with 'GetPropertyChangedSignal'

I’m trying to make it so that if you go below 25 health, your player screams “MEDIC BAG!”

Everythings working so far, but I keep getting this error.

Workspace.coffeeman1256.medicbag:5: attempt to index number with 'GetPropertyChangedSignal'

Ive tried changing player:GetPropertyChangedSignal to player.value:GetPropertyChangedSignal, which is the only fix I’ve found, but it now pops up a new error,

Workspace.coffeeman1256.medicbag:5: attempt to index number with 'Value'

Heres the script.

local player = script.Parent.Humanoid.Health
local numval = script.Value

wait(5)
player.Value:GetPropertyChangedSignal("Value"):Connect(function()
	local noise = script.Parent.Head.noise
	if player.Value <= 25 then
	---	numval.Value = math.random(1, 100)
	---	if numval.Value <= 10 then
			noise:Play()
		end
	end)

Try using .Changed instead of GetPropertyChangedSignal

i will assume this is A number value Instance

local player = script.Parent.Humanoid.Health --

if so then u need to deleted and do this instead

local player = script.Parent.Humanoid
local numval = script.Value

wait(5)
player.Value:GetPropertyChangedSignal("Health"):Connect(function()
	local noise = script.Parent.Head.noise
	if player.Health <= 25 then
	---	numval.Value = math.random(1, 100)
	---	if numval.Value <= 10 then
			noise:Play()
		end
	end)

If you want the player to scream ‘medic bag’ when their health is lower than 25 do the following:

local PlayerService : Players = game:GetService("Players")

local function onPlayerAdded(player : Player) -- player handler
	local function onCharacterAdded(character) -- character handler
		local humanoid : Humanoid = character:WaitForChild("Humanoid")
		
		local debounce = false -- so you dont spam scream
		humanoid:GetPropertyChangedSignal("Health"):Connect(function()
			if humanoid.Health <= 25 and not debounce then
				debounce = true
				-- Play scream sound effect
				task.wait(50) -- until you can scream again
				debounce = false
			end
		end)
	end

	if player.Character then onCharacterAdded(player.Character) end
	player.CharacterAdded:Connect(onCharacterAdded)
end

for _, player in pairs(PlayerService:GetPlayers()) do onPlayerAdded(player) end
PlayerService.PlayerAdded:Connect(onPlayerAdded)

This should be a server script under ServerScriptStorage.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.