Script only detecting characters partss

This touch event is only detecting the characters parts and nothing else. Im not sure why here is the code. Only printing the players parts

model.PrimaryPart.Touched:Connect(function(hit)
	print(hit.Name)


	if hit.Parent and hit.Parent.Name == model.Name then
		MergeEvent:FireServer(hit.Parent, model)
	end
end)

What are you basically trying to do to the player?

So, it’s printing the player characters’ parts because the model’s PrimaryPart is only touching a limb, so in order to print the character/player’s name you would have to do something along the lines of print(hit.Parent.Name).

I like to add an if statement such as if hit.Parent:FindFirstChild("Humanoid") ~= nil then..., just for good practice given you want to make sure you’re detecting a character.

Some more explanation would also be helpful, though like Shawn said.

Im not trying to do anything to the player, im trying to detect if two parts collide with each other. But its only detecting the players characters parts.

No im not trying to detect the player, im trying to detect other parts in workspace. its touching them but somehow not detecting them. This is the first time ive ever encountered this issue,

You can try using BasePart:GetTouchingParts with one touch event

Already tried that im having the same issue.

how did you use it in the script?

local model = game.Workspace.boat1
local UserInputService = game:GetService("UserInputService")
local camera = workspace.CurrentCamera

model.PrimaryPart = model["Meshes/boat1_Cube"]
local isDragging = false
local highlight = nil


local MergeEvent = game.Workspace:FindFirstChild("MergeEvent")
if not MergeEvent then
	MergeEvent = Instance.new("RemoteEvent")
	MergeEvent.Name = "MergeEvent"
	MergeEvent.Parent = game.Workspace
end

local function onInput(input, gameProcessedEvent)
	if input.UserInputType == Enum.UserInputType.MouseMovement then
		local hit = game:GetService("Players").LocalPlayer:GetMouse().Target
		if hit and hit:IsDescendantOf(model) then
			if not highlight then
				highlight = game.ReplicatedStorage.MergingSystemMain.Highlight:Clone()
				highlight.Parent = model
			end
		else
			if highlight then
				highlight:Destroy()
				highlight = nil
			end
		end

		if isDragging then
			local mousePosition = input.Position
			local ray = camera:ScreenPointToRay(mousePosition.X, mousePosition.Y)
			local worldPosition = ray.Origin + ray.Direction * ((-0.9 * ray.Origin.Y) / ray.Direction.Y)
			model:SetPrimaryPartCFrame(CFrame.new(worldPosition))
		end
	end
end

local function onInputEnded(input, gameProcessedEvent)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		isDragging = false
	end
end

local function onInputBegan(input, gameProcessedEvent)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		local mouseHit = game:GetService("Players").LocalPlayer:GetMouse()
		local hitPart = mouseHit.Target
		if hitPart and hitPart:IsDescendantOf(model) then
			isDragging = true
			UserInputService.InputChanged:Connect(onInput)
			UserInputService.InputEnded:Connect(onInputEnded)
		end
	end
end

model.PrimaryPart.Touched:Connect(function(hit)
	print(hit.Name)


	if hit.Parent and hit.Parent.Name == model.Name then
		MergeEvent:FireServer(hit.Parent, model)
	end
end)

UserInputService.InputBegan:Connect(onInputBegan)


Maybe you should take a look at your conditionals. Are you sure you want the thing the player is colliding with to have the same name as the model? Maybe you meant to do a “~=” operator?

Well right now all im concerned about is the printing, because right after the touched event fires its only detecting the player. There are no conditionals at that point.

Are you doing this in a local script or server script?

Local, I tried both. Gave me the same result.

So add some! Maybe something like, if not model:FindFirstChild((hit or hit.Parent)) then... print(hit.Name)?

which parent class do you have the script in rn?

I dont need them currently to print the stuff.

currently in StarterPlayerScripts

Propably try moving that to startercharacterscripts since you’re dealing with stuff inside the players character.

image

Could you explain what you’re specifically trying to accomplish in this script and what you want it to print exactly?

The thing is im not trying to deal with the character. I dont want it to only detect the character, i want it to detect workspace parts. I have no clue why this is happening either it was working fine on my other scripts the other day