I have a part in Workspace named Part and inside it is a script, I want that script to on touched get the player's name that has just touched the part and put their name in a GUI
local playername = game.StarterGui.checkinGui.mainFrame.playerName local plrname = game.Players.LocalPlayer function onTouch() playername = plrname.Name end script.Parent.Touched:connect(onTouch)
Using a normal Script btw, not a LocalScript.
The way to do this via ServerScript would be :GetPlayerFromCharacter()
which does exactly what you would think it does, gets the player from a character.
--in a ServerScript script.Parent.Touched:connect(function(part) local maybePlayer = game.Players:GetPlayerFromCharacter(part.Parent) if maybePlayer then --if it's a player local name = maybePlayer.Name --other stuff here end end)
Not 100% sure this will work and may require some tweaking to your situation, but this is what I got.
--Here is the local script running ON YOUR PERSON local Event = repStorage:WaitForChild("YourRemoteEvent") part.Touched:connect(function(hit) if hit.Parent == game.Players.LocalPlayer then Event:FireServer(hit.Parent) end end) --Here is the server script local Event = repStorage:WaitForChild("YourRemoteEvent") Event.OnServerEvent:connect(function(player, hit) NavigateToWhereTheTextIs.Text = hit end)
Like I said, you need to tweak it a little bit, but I think it SHOULD work. I didn't test it so if it doesn't try your best to figure it out, or just reply asking.
Try This:
--Thanks jamiethegreatQ777 For Making This :) Credit To jamiethegreatQ777 = true if Credit To jamiethegreatQ777 == false then return end game.Workspace.part.SurfaceGui.TextBox.Text = game.players.Localplayer "..PlayerName.."
I'm Sure This Will Work If Not Please Message Me twitter.com/jamiethegreatQ7