Detecting when newPart touches a Basepart

Here is what it looks like

Here is what I want it to look like

Local script:

local character = player.Character or player.CharacterAdded:Wait()
local RightArm = character:WaitForChild("Right Arm")

local backpack = player:WaitForChild("Backpack")
local mouse = player:GetMouse()
local cube = game.ReplicatedStorage:WaitForChild("Cube")
local equipped = false
local debounce = true

mouse.Button1Down:Connect(function()
	if equipped == true and debounce then
		debounce = false
		
		local newPart = cube:Clone()
		newPart.Position = RightArm.Position 
		newPart.CanCollide = false
		newPart.Parent = workspace
		
		local hitPosition = mouse.Hit.Position 
		newPart.CFrame = CFrame.lookAt(newPart.Position, hitPosition)
		
		local LinearVelocity = newPart.LinearVelocity
		LinearVelocity.MaxForce = math.huge
		LinearVelocity.VectorVelocity= newPart.CFrame.LookVector * 40
		wait(.3)
		LinearVelocity:Destroy()
		wait(.3)
		debounce = true
	end
end)


character.DescendantAdded:Connect(function(descendant)
	if descendant:IsA("Tool") then
		equipped = true
		print("equipped")
	end
end)

character.DescendantRemoving:Connect(function(descendant)
	if descendant:IsA("Tool") then
		equipped = false
		print("unequipped")
	end
end)

How would I make it so it can detect when it touches something? I can’t use Touched event in local script. I just honestly don’t really know how to go about this.

1 Like

You can use touched event in local scripts! If for any reason you need it to damage players, you can fire a remote event to the server that will deal damage on the server. If you need it to destroy a part, you can also fire a remote event to the server that will destroy the part on the server

1 Like

Wait but what huh my brain. Why did I think I can’t use touched events. I’m sorry for my brain malfunction. I think I read ChatGPT saying that I can’t and my brain didn’t reconsider.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.