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

Functions not running when I call them?

I've once more come here to ask about my fall damage. the problem I'm having now is that I want it so if a command is run it puts you on a list that makes it so you no longer have fall damage. I have the command system working, but my function doesn't run when it should.

local HeightRequired = 10
local DamageScale = 2.5 
local exluded = {}
local new = script.New

script.New.Changed:Connect(function()
	for index = 1, #exluded, 1 do					
		if new.Value ~= exluded[index] and index == #exluded then
			for i, plr in pairs(game.Players:GetPlayers()) do
				if new.Value == plr.Name then
					table.insert(exluded, #exluded + 1, new.Value)
					print("added "..new.Value.." to exluded list")
					new.Value = ""
					break
				end
			end
		elseif new.Value == exluded[index] then
			print(new.Value.." is already on exlude list")
			break
		end
	end	
end)

game.Players.PlayerAdded: Connect(function(Player)
	Player.CharacterAdded: Connect(function(Character)
		local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
		local Humanoid = Character:WaitForChild('Humanoid')
		
		local StartJump = nil

		Humanoid.FreeFalling:Connect(function(Active)
			if Active then
				StartJump = HumanoidRootPart.Position.Y
			else
				local JumpHeight = StartJump - HumanoidRootPart.Position.Y
				
				if JumpHeight > HeightRequired and Humanoid.FloorMaterial ~= Enum.Material.SmoothPlastic then
					for index = 1, #exluded, 1 do
						if Humanoid.Parent.Name ~= exluded[index] and index == #exluded then
							Humanoid:TakeDamage((JumpHeight - HeightRequired)*DamageScale)
							break
						elseif Humanoid.Parent.Name == exluded[index] then
							break
						end
					end				
				end
			end
		end)
	end)
end)

I can't seem to find the error in this mainly because nothing comes up in the output, my fall damage just stops working even if I'm not on the list.

as always any help is appreciated.

3 comments

0

So wait, is New a value?

0

Never mind, that was a stupid question. What I meant to ask was what exactly is being passed through the Active parameter? I don't have good experience with this event, so I would need to know how it works.

0

Never mind, that was a stupid question. What I meant to ask was what exactly is being passed through the Active parameter? I don't have good experience with this event, so I would need to know how it works.

1 answer

✓ Accepted answer

I managed to fix the issue, it was simply solved by adding a dummy value into the table so that the for loops wouldn't break.

1 comment

0

Great!

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