Hi. So I’m trying to get where if the player touches the “ShiftStartPart” that the GUI shows up. The code works, but when one of the players hits the part the GUI shows up for everybody instead of only for the player who touched it. I’m not that advanced in scripting since I mostly do UI Modeling, but if someone could help me out to make it where the UI only shows up for the person who touched it, not for everyone when 1 player touched the part, that would be amazing!
Actually, now that I am thinking about it, I have a feeling you put this touched event inside of a PlayerAdded event’s function. If this is true, just reply and I will help you fix it.
What I suggest you do is compare the player who touched the part to the player that needs to receive the notification (which in this case is the player that hit the part). We can use the first argument thats passed in the Touched function (which is the part that hit).
So you could do something like:
local PS = game:GetService("Players");
local Player = PS.LocalPlayer; -- Assuming its a local script
ShiftStartPart.Touched:Connect(function(Hit)
local HitPlayer = PS:GetPlayerFromCharacter(Hit.Parent);
if HitPlayer and HitPlayer == Player then
-- Continue logic here
end;
end)
Might be typos as I’m on mobile but hopefully this gives you a general idea.