On touch script not working

Hi friends,
I am trying to do a script that when player spawn, will touch a part. The script works fine, but if 2 players or more touch the part while someone is, it’s not working.

script.Parent.Touched:Connect(function(plr)
	plr.PlayerGui:FindFirstChild("ScreenGui").TextButton.Visible = true
end)

Does anyone know where is the issue? - Thanks!

1 Like

are you sure this script is working ?

1 Like

script.Parent.Touched:Connect(function(p)
local plr = game:GetService("Players"):GetPlayerFromCharacter(p.Parent)
if plr then
plr.PlayerGui:FindFirstChild("ScreenGui").TextButton.Visible = true
end
end)

Try this! :slight_smile:

2 Likes

the issues is

the plr isnt actually the player the function gives you the Hitpart which is touching could be basepart of the Character and try @VisuallyFX method

2 Likes