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

Why aren't players taking damage from the Hitbox even when it spawns on them?

Rep.Events.Combat.OnServerEvent:Connect(function(Player, Action)
	if Action == "Light" then
		local hit = false
		local Character = Player.Character or Player.CharacterAdded:Wait()
		local Hitbox = game:GetService("ServerStorage").Hitbox:Clone()
		Hitbox.Parent = workspace
		local offset = Vector3.new(0,0,-2)
		Hitbox.CFrame = Character.HumanoidRootPart.CFrame*CFrame.new(offset)
	
		wait(.15)
		Hitbox.Parent = nil
		Hitbox.Touched:Connect(function(Touched)
			if not hit and not Touched:IsDescendantOf(Player.Character) and Touched.Parent:FindFirstChild("HumanoidRootPart") then
				hit = true
				Touched.Parent:FindFirstChild("Humanoid"):TakeDamage(10)		
					FX.Parent = workspace
					FX.CFrame = Touched.Parent.HumanoidRootPart.CFrame*CFrame.new(math.random(-10,5)/15,math.random(-10,5)/15,math.random(-10,5)/15)
			end
		end)
		wait(.2)
		FX.Parent = nil
	end
end)

1 answer

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