Hi guys, this is my first ever question on here. So I'm trying to make a Camping-like game it is called Truth or Dare. All the other scripts work except for this one. The script is supposed to make a GUI pop up once a player touches a specific part. But when I touch the part, I look at the output and an error has popped up saying, "ally_playz336 is not a valid member of Players." So here is the script:
local GUI = script.Parent.ScreenGui -- You might want to change this to whatever your GUI is.
script.Parent.PlayerTouched:connect(function(hit)
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
local plr = game.Players(hit.Parent.Name)
if plr:FindFirstChild("PlayerGui") and not plr.PlayerGui:FindFirstChild(GUI.Name) then
GUI.Clone().Parent = plr.PlayerGui
end
end
end)
I don't know if there is anything wrong with it, because it looks fine to me. The only problem is that it won't work. Help is greatly appreciated ????

8 comments
@fighterkirbyzx It still doesn't work. Another error has popped up in my output saying, "16:55:45.783 - Workspace.GUIGiver.Script:6: Expected '(', '{' or , got 'if'" I don't think it works :(
what line was the error?
@manith513 The error had a 6 in it, so I think it may be on line 6.
wiat
what? :|
I know the issue
use game:GetService:("Players"):GetPlayerFromCharacter(hit.Parent) instead
i forgot the () ;-;