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

Why Isn't this script hitting a whole group of people when touched?

this is a script for a bomb power in my game but every time when I press the button to blow it up it only hits one person.

WHY!?

HOW Do I make it hit Any one who touches it onece? not just one person when everyone gets hit by the blast!?

local Remote = game.ReplicatedStorage.BombFruitRemotes.Move1Event	
	
local hithum = false

local died = false

Remote.OnServerEvent:Connect(function(plr)
	
	local char = plr.Character or plr.CharacterAdded:wait()
	local hum = char.Humanoid
	local explodeclone = game.ReplicatedStorage.Explopart:Clone()
	
	
	explodeclone.Parent = game.Workspace
	
	explodeclone.CFrame = char.HumanoidRootPart.CFrame
	
	explodeclone.Touched:Connect(function(hit)
		local ehum = hit and hit.Parent:FindFirstChild("Humanoid")
		if ehum and ehum ~= hum then
			if hithum == false then
		hithum = true
			ehum:TakeDamage(20)
			print(hit.Parent.Name)
			end
		end
	
	end)
	
	
for i = 1,20 do
		wait()
		explodeclone.Size = explodeclone.Size + Vector3.new(4,4,4)
	end
	wait(.5)
	explodeclone:Destroy()		



end)
--hum.Died:Connect(function()
--	died = true
--end)




---/Script by Tizzel40/---/Bomb Move 1 (I)

1 comment

0

u mispelled once to onece

1 answer

im guessing is u add debounce and didnt make said debounce affect a single player but all said debounce did affect so u only ended up hitting one guy due to said debounce.

In other words, make the debounce player specific. Since u didnt post the entire script; im unable to alter said entire script, but i can give u an example of player specific debounce:

place in a script in a part; in the workspace; the part will deal damage to a humanoid if said humanoid is not in the debounce table:

local part = script.Parent
local debounce = {}

part.Touched:Connect(function(hit)
	local hum = hit.Parent:FindFirstChild("Humanoid")
	
	if hum then
		local gotChar = false
		
		for i, v in pairs(debounce) do -- scan the table for the character
			if v == hit.Parent then
				gotChar = true
			end
		end
		
		if not gotChar then
			table.insert(debounce, hit.Parent)
			
			hum:TakeDamage(30)
			
			wait(1)
			for i, v in pairs(debounce) do
				if v == hit.Parent then
					table.remove(debounce, i)
				end
			end
		end
	end
end)

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