-- Called when a new character model is created

local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")
	local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
	local floorChangedSignal = humanoid:GetPropertyChangedSignal("FloorMaterial")
	
	-- Create fire effect to show the player if they are taking damage
	local fire = createFire()
	fire.Parent = humanoidRootPart
	
	-- Connects function to when the floor under the character changes
	signalBindings[character] = floorChangedSignal:Connect(function()
		-- If the character is standing on lava, add them to the list of on fire
		-- characters and turn on the fire effect. Otherwise to the opposite
		if humanoid.FloorMaterial == Enum.Material.CrackedLava then
			charactersOnFire[character] = true
			fire.Enabled = true
		else
			charactersOnFire[character] = nil
			fire.Enabled = false
		end
	end)
end
