✓ Accepted answer
Hey beastboy8171,
There is a problem with your script. The problem is: It's a ServerScript and you can't access LocalPlayer from ServerScripts and you can't use LocalScripts in the server. You must only use ServerScripts in the server and you must only use LocalScripts in the Client. But, there's a solution to how you can go about getting the player from the Server Script and be able to do what you are doing, just from a simple ServerScript. The event .Touched has a parameter of the part which is touching. In order to get to the Player, you must make sure that the part which is touching is from the Character of a player. This is most commonly checked by checking if you can find the object Humanoid inside of the parent of the part which is touching. So, all you have to do is use the :FindFirstChild() method for the part's parent and try to see if it contains a Humanoid. Here is the wiki page about that method and below is a personal example.
local hum = part.Parent:FindFirstChild("Humanoid")
###After that just check it's existence with a simple if statement. So afterwards, if it passes the if statement, you know that the object that touched the Part is from a Character. So, you can easily define Character as being the object's parent. Now, here you might get introduced to a new method that you didn't know about. Let me introduce you to a simple method you can use to get the Player from the Character. It's called :GetPlayerFromCharacter I know right, pretty simple. Here is the wiki page for it and below is a personal example.
local character = part.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(character)
#After you have the parent, you can just locate the PlayerGui and find what you need and mutate it's properties as you may like. I hope this helped and have a great day/night.
~~ KingLoneCat
1 comment
works*