Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Nootian 184
5 years ago
Edited 5 years ago

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)
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.  royaltoe 5144 — 5y

1 answer

Log in to vote
0
Answered by
Nootian 184
5 years ago
Edited 5 years ago

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
Ad

Answer this question