Touched not working on certain part

Okay so I’m not sure how to explain why it’s not working I doubt anyone else would be but I wouldn’t know so I’m going to ask either way.

So pretty much i have this portal and i want it to teleport the player to somewhere when you enter it but it doesn’t detect the player touching it


image
image

I tried making a hitbox for the portal instead of using the same part but that didn’t work that’s why there is two parts btw

4 Likes

Does the part have CanTouch enabled? Can you add more print statements?

Yes it has cantouch enabled i’ve made sure that wasn’t the issue before i reported it here

1 Like

What I usually do for hit detection is to check if the hit.Parent has a player, since hit.Parent can be a part of an accessory.

script.Parent.Touched:Connect(function(Object)
	local player = game.Players:GetPlayerFromCharacter(Object.Parent)
	if player then
		local hum = player.Character:FindFirstChild("Humanoid")
		if not cooldown then
			cooldown = true
			print("hi")
			wait(1)
			cooldown = false
		end
	end
end)
1 Like

Is the “print(“hi”)” showing up in the output?

1 Like

Are you sure you are touching the part? Why don’t you put the script inside of baseplate to see if it’s printing hi.

Script:

local teleportDestination = workspace.TeleportDestination
local portal = script.Parent
local cooldown = false

portal.Touched:Connect(function(hit)
    local character = hit.Parent
    if character:IsA("Model") and character:FindFirstChild("Humanoid") and not cooldown then
        cooldown = true
        print("Teleporting...")
        
        local destinationPosition = teleportDestination.Position
        character:SetPrimaryPartCFrame(CFrame.new(destinationPosition))

        wait(1)
        cooldown = false
    end
end)

2 Likes

tried this but on like a regular part and it works

I’ve tried multiple way even just removing checks of it even being a player also led to nothing happening

could you try cloning the portal out of curiosity to see if that prints anything

This is a case where the issue is most likely being caused by the way something is built instead of a problem with the script because I tested the script exactly as it is written in the screenshot both on a single part and in a hitbox part inside of a larger part and Touched did detect correctly (the only time it failed was when I tried making the hitbox part very small compared to the parent part). I recommend you try these steps:

  1. Make the Script a child of Portal2 instead of the hitbox Part
  2. Delete the hitbox part as it shouldn’t be necessary in your case
  3. Be extra sure CanTouch is true for the Portal2 part

If you follow these steps and the function still doesn’t run then the possible problems I can think of are:

  • There might be other lines inside of the script where the Touched event is that’s preventing it from working since in the screenshot provided the line numbers aren’t visible so we don’t know if it’s the full code
  • Another script is interfering with either the Portal2 Part or the script
  • A plugin you have installed in Studio is interfering

If it works for the baseplate or another part which doesn’t contain particles why don’t you try to delete that particle. Or maybe I am guessing your hitbox is inside of that particle part if you are using diffrent parts for particles and hitbox.

I’ve done everything no other script could be interfering and the screenshot i had shown from the code above was the full code just like the guy under here said i think it’s most likely that the particles are the reason it’s not working properly but i do still need the particles since without them there’s no portal so I have to find a way around it

Why don’t you try making a new hitbox a new part and just make the particles a diffrent part?

If the particles are causing the problem then it’s most likely a bug as that shouldn’t be happening

I suggest you try making the hitbox part slightly bigger than the Portal2 part and if that still doesn’t work then report this as a possible bug to Roblox

That’s pretty much how it’s done now and still doesn’t work

Tried making the hitbox bigger and it still didn’t work I’m sure it has something to do with the particles

Is it possible to get a game file only containing the portal and the script ?

I wish you luck finding a solution to this problem. I too suspect there might be something wrong with the particles but unfortunately I’m on mobile now so I won’t be able to test the theory

try printing the Object and Object’s Parent if the event actually functions?