Script refusing to work and nothing in the output

For the past few weeks, I have been making a huge revamp for my zombie game. It has an endless amount of waves, but there is a few more things I want to do before releasing the new update. One of them is a really annoying bug fix.

Below is the script causing the problems. For some reason, the message for when the core is destroyed will not appear. The core also will not heal after every wave. The healing after every 2.5 seconds is the only thing working. The script is inside of a humanoid. There is also nothing in the output.

This is the script:

local values = workspace:WaitForChild("Values")
local wave = values:WaitForChild("Wave")

while wait(2.5) do
	script.Parent.Health += 1
end

--ALL OF THIS WILL NOT WORK FOR SOME REASON
--IF YOU KNOW HOW TO FIX IT, PLEASE DO.
--I WILL MAKE A POST ON THE DEV FORUM SO THAT I CAN GET HELP

script.Parent.Died:Connect(function()
	local message = Instance.new("Message")
	message.Parent = workspace
	message.Text = "The zombies have destroyed your core!"
	wait(2.5)
	message.Text = "Shutting down server. Please don't leave and rejoin until you are kicked or you might reconnect to this server."
	wait(5)
	for i, v in pairs(game.Players:GetChildren()) do
		v:Kick("The core has been destroyed. Please rejoin. This is just a temporary screen, and will be replaced in a later update.")
	end
end)

wave:GetAttributeChangedSignal("Value"):Connect(function()
	script.Parent.Health += 500
end)

I’ve been trying to fix this for 30 minutes now but to no avail. If I cannot get this to work then the release date will be delayed.

Please let me know of any fixes for this. Thank you!

1 Like

the script wont continue since the while true do is a loop, meaning the scripts stops threading

u can just do this to prevent that from happening

task.spawn(function()
	while wait(2.5) do
		script.Parent.Health += 1
	end
end)
2 Likes

That seems to have fixed part of the problem but this still isn’t working.

wave:GetAttributeChangedSignal("Value"):Connect(function()
	script.Parent.Health += 500
end)

Any possible fixes for that? Thank you!

1 Like

make sure the attribute is actullay called “Value” and not something else

1 Like

Are you sure it has this attribute, and is not a Value Object instead? If it is a value object, you need to use GetPropertyChangedSignal(“Value”) instead.

1 Like

Let me try replacing GetAttributeChangedSignal(“Value”) with GetPropertyChangedSignal(“Value”). Will let you know if that works.

edit: It seems to have fixed the problem. Thank you so much!

1 Like

For ValueBase objects you should use .Changed instead.