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

This script won't return end when it hits block part can anyone help?

local Combo1 = RP.PunchEvents.Combo1

local BlockPart = game.Workspace:FindFirstChild("BlockPart")

Combo1.OnServerEvent:Connect(function(plr)
	local RigthArm = plr.Character["Right Arm"]
	
	plr.Character.Humanoid:LoadAnimation(script.LightAttackAnims.LightAttack1):Play()
	
	local CanTake = true
	local dmg = 5
	
	RigthArm.Touched:Connect(function(hit)

		if hit.Parent == plr.Character then return end
		if hit.Parent == BlockPart then return end
		if  hit.Parent:FindFirstChild("Humanoid") and CanTake == true then
		

		
			local enemyHum = hit.Parent:FindFirstChild("Humanoid")
			CanTake = false
			enemyHum:TakeDamage(dmg)
	
				end
	end)
end)

This script is supposed to return end when it hits block part but when it does it just deals damage can anyone help me?

1 comment

0

your function runs before you even get to the return end part

1 answer

When you hit blockpart, hit.Parent would be workspace try

if hit==BlockPart then return;end;

12 comments

0

It did not work and I got no errors

0

Does that imply that BlockPart does not exist?

0

The part exists for sure.

0

maybe the part didnt load yet, try local BlockPart = Workspace:WaitForChild("BlockPart")

0

Im gonna try when i wake up sorry for my late replies im just busy irl atm

0

another suggestion: put the rightarm event on the outside of the Onserverevent, that event wont activate unless onserverevent is activated

0

The wait for child did not work and putting the righarm event outside of the onserverevent breaks it

0

Again with no errors

0

Anything special about variable blockpart or is it a regular part?

0

Just a normal part

0

Oh well yoy better put some print functions just to check

0

Its quite clear, if the solution i provided doesnt work then theres something that i dont know

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