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

Is there a different function I can use other than .Touched?

For some reason .Touched lags my game when there is multiple beams fired and when it touched character, the character start lagging on there client side. Heres the server script code on remote function or touch interest

part1.Touched:connect(function(touched)
			if touched~= nil then
						if touched.Parent then
			if touched.Parent:FindFirstChild("Humanoid")~= nil then
				if touched.Parent.Name ~= char.Name then
				if touched.Parent:FindFirstChild("Kamehamehad")== nil then
					
				damage = 2
	if char:FindFirstChild("SSJ")~= nil then
		damage = damage + 1
	end
	if char:FindFirstChild("SSJ2")~= nil then
		damage = damage + 1.5
	end
	if char:FindFirstChild("SSJ3")~= nil then
		damage = damage + 2
	end		
	if char:FindFirstChild("SSJB")~= nil then
		damage = damage + 2.5
	end
	if char:FindFirstChild("LIMIT")~= nil then
			damage = damage + 3
	end
		if touched.Parent:FindFirstChild("Block") == nil then
			touched.Parent:FindFirstChild("Humanoid").Health = touched.Parent:FindFirstChild("Humanoid").Health - damage
		else
			touched.Parent:FindFirstChild("Humanoid").Health = touched.Parent:FindFirstChild("Humanoid").Health - (damage/1.2)
		end
				km = Instance.new("StringValue",touched.Parent)
				km.Name = "Kamehamehad"
				game.Debris:AddItem(km,0.1)
				
				
				
			end
				end
				end
			
					end
			end		
		end)

8 comments

1

Err: Could not read code - Didn't indent propely... ErrCode: #EF0AA4F

0

what is this absolutely random indenting

0

Talking about his indenting instead of helping. Le classic.

0

im asking if theres another hit detection/.touched function other then touch interest

0

use magnitude

0

magnitude is good but how to i use it on all size of the part like is a part is V3.new(1,20,1) i ant to see if player is inside the block

0

20/10 = 10 so 10 studs right?

0

if you indent then indent correctly. If you don't indent at all, that is better than random indents. I don't know what in the world you do.

1 answer

Use a debounce and it won't lag so much also please let roblox indent instead of spamming random spaces everywhere here is an example

alreadytouched = false
part.Touched:connect(function(hit)
	if not alreadytouched then
		alreadytouched = true
		--code here
		wait(1)
		alreadytouched = false
	end
end)

1 comment

0

local variables

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