How to detect when a player is touching and touching a part

Unless you did that. I’m new to scripting. :man_facepalming:

It is still the last code i didn’t change anything

1 Like

So when you run this the gui appears and then disappears and never appears again?

1 Like

When it does appear again but then just disappears

1 Like

Can I see the code you got on the client for making the gui appear

2 Likes

1 Like

remove hit.Parent:FindFirstChild(“HumanoidRootPart”) that is unneeded.

1 Like

the same thing happens still when I remove it.

1 Like

Could you send the whole script that this code is in.

1 Like

The script is very long with 217 I cant fit it all in with a screen shot

1 Like

This is weird. From what i see your code is fine but like i said only Humanoid is needed the others might be what making the gui acting weird. Have you tried remove the other?

1 Like

What do you mean by remove the other?

1 Like

I mean remove the Other_Part.Parent.Name == Plr.Name just keep the humanoid check

1 Like

I did and the same thing keep happening

1 Like

One possible solution to this issue is to use a local script to listen for the Touched event on the client side, rather than using a server script. This can help reduce latency and improve the responsiveness of the GUI. According to a post on the Roblox Developer Forum(How to make GUI appear and disappear when touching and not touching part), you can use a local script to listen for the Touched event and fire a remote event to show or hide the GUI.

Another possible solution is to use regions to detect when the player enters or leaves an area, rather than relying on the Touched and TouchEnded events. According to a post on Reddit (Reddit - Dive into anything), you can create regions where the player is detected and show or hide the GUI based on whether or not the player is inside the region.

1 Like

Also the Plr is somewhat wrong. it is a server script. Are you doing this with characteradded?

1 Like

btw yeah, it seems that the Plr variable is not defined in the code he provided. If this is a server script, you may need to define the Plr variable by using the CharacterAdded event of the Players service, example:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local Plr = player
        -- Your code here
    end)
end)
1 Like

nothing is working. Am not sure why

1 Like

Can we see your hitbox properties?