Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

{Solved}How do I find the player with a button GUI using a surface gui as parent?

Is there a way to find the player without a local script? or is there a way to get the name of the player with something else? Would I be able to use a parameter for this and how do I find the variable player?

Link = "510411669"
local TeleportService = game:GetService("TeleportService")

function B1()
if player then
	TeleportService:Teleport(Link, player)
end

Button.MouseButton1Click:connect(B1)

1 comment

0

You can do the mousebutton1click logic in a local script and then fire the server telling the server to teleport the player using remote events. The first parameter of a remote event is always the player that fired the event. 

1 answer

Ok i did it and it works!

Where you should put your local script: A Player’s Backpack, such as a child of a Tool A Player’s character model A Player’s PlayerGui A Player’s PlayerScripts. The ReplicatedFirst service

Local Script: (Game.StarterPlayer.StarterPlayerScripts)

function B1(player)
	
	RemoteEvent:FireServer(game.Players.LocalPlayer.Name)
end

Button.MouseButton1Click:connect(B1)




Script: (Anywhere)

function player(Person)
print(Person)
end

RemoteEvent.OnServerEvent:Connect(Person)

If person = "noot20000" it will print the name

--Output:      noot20000

This discussion is preserved as it was. New answers, comments, and votes are closed.