Fire System Not Decreasing Health In Region

So I am trying to make a Fire System to where if you walk into the fire your health gets slowly subtracted only when inside the fire area, therefore when you walk out of the fire it stops taking damage.

I’ve followed a tutorial on Sound Regions and tried to edit it but it failed.

The Workspace Files (All the trees are the same)
image

The LocalScript

Where the LocalScript is located
image

Output on Play

Currently when I walk into the fire it doesn’t work and nothing pops up in the output.

I’m not sure what to do here so If I can get some help that would be amazing!

Uh… Hold up. You are trying to change the health in a Local Script?
Uh buddy? I got something to tell you.

Closer…

Closer…

You can’t change health from a local script.

You can’t be changing your health in a LocalScript… I mean you can but it won’t replicate to the server, and if your health is 0 on the client, your character will probably just die.

I think my way of saying it is much funnier

Literally shows an error from Script Line 7. (Whatever is red is an error)

Even if it had no errors, it wouldn’t work anyway because @Nasher986 put the code in a local script and not a server script :confused:

Yeah I agree with you, just trying to inform him that something did show in the output. Didn’t think repeating what was already said would be helpful haha

@Nasher986 Put this in a server-sided script. Preferably, I would place it in ServerScriptService.

local FireRegionsWorkspace = game.Workspace:WaitForChild("FireRegions")

local function getCharacters()
	local list = {}
	for _,plr: (Player) in pairs(game.Players:GetPlayers()) do
		if plr.Character then
			table.insert(list,plr.Character)
		end
	end
	return list
end

while task.wait(1) do
	local damagedPlayers = {}
	for i,v in pairs(FireRegionsWorkspace:GetChildren()) do
		local firePart = v.FirePart
		local region = Region3.new(firePart.Position - (firePart.Size/2),firePart.Position + (firePart.Size/2))
		local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, getCharacters())
		for _, part in pairs(parts) do
			local player = game.Players:GetPlayerFromCharacter(part.Parent)
			if player and table.find(damagedPlayers,player) == nil then
				if firePart.ParticleEmitter.Enabled == true then
					table.insert(damagedPlayers,player)
					local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
					if humanoid then
						humanoid:TakeDamage(10)
					end
				end
			end
		end
	end
end

@Nasher986 Did you mistake the region for the firepart?

1 Like

The error is for another script I was working on, not related to this current script.

But… That doesn’t change the fact…

It does change on the client, but doesn’t replicate to the server, and unlike walkspeed or jumppower they do not affect the character in any way. If it did, the exploiters can become god via

game:GetService("Players").LocalPlayer.Character.Humanoid.MaxHealth = math.huge
game:GetService("Players").LocalPlayer.Character.Humanoid.Health = math.huge

I know it does not change the fact.

I found out that it was also a problem where I placed the FirePart so I will need to find the issue.

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