How do i mention the player itself?

Hello!

So i made a admin panel.

But it was not made for more players, just for me. And i just wanna ask how do i mention the player who clicks the button?

EXAMPLE: Player1 Clicks the Clone button and the character of Player1 has cloned. But for me it’s only for a specific player. Like instead of Player1 (The admin) Player2’s character gets cloned (The game creator)

3 Likes

Depends on how you’d wanna implement it

If you want to clone the Target Player using a TextBox, you’d need to use RemoteEvents to accomplish that

What RemoteEvents are, is basically client-server transportation which can send data from 1 side to the other, making it more efficient & easier to get both of the Players

What you could do, is put a LocalScript inside a TextBox object, type the Text then after the text’s focus is lost you can fire a RemoteEvent like this:

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local TextBox = script.Parent

TextBox.FocusLost:Connect(function(PressedEnter)
    if PressedEnter then
        Event:FireServer(TextBox.Text) --This will be passed onto the server to receive 
    end
end)

And then on a ServerScript, preferably inside ServerScriptService we can get all the Players using a loop & check if the Text that we passed is equal to 1 of the Player Names:

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

Event.OnServerEvent:Connect(function(PlayerWhoFired, TargetPlayer)
    for _, Player in pairs(game.Players:GetPlayers()) do
        if Player.Name == TargetPlayer then --This will check if the specific player name is equal to the TargetPlayer (Or thatrandomnoob23 == thatrandomnoob23)
            Player.Character.Archivable = true

            local CharacterClone = Player.Character:Clone()
            CharacterClone.Parent = workspace
            
            Player.Character.Archivable = false
        end
    end
end)

On a OnServerEvent, the Player that fired it will always be the first parameter, then afterwards we can use our Text that we sent from the client

Another thing, but by default the Player’s Character Archivable property is set as false by default, (Or we’ll be unable to clone it) which is why we must set it to true first before creating our CharacterClone variable

1 Like

You should use RemoteEvents right here

@Jackscarlett I wanna make it by a simple button. But i will do the TextBox version. Thank you!

If you just simply mean like detecting when the Player clicks the button, you’d still need to use RemoteEvents if you’re wanting everyone to see the mention

Doing it on the client alone would just result in only you seeing it

And as I referenced before, you can use the Player parameter to reference the Player that fired the Event

If you want to know more stuff about TextBox then check it out here.

One question. How do i move the TextBox? Becuase everytime i click on it, it selects the AdminFrame.

What do you mean by that? :thinking: Are you talking about Studio Editing, or Studio Ingame?

Studio Editing, when i select the TextBox, it selects the AdminFrame. (TextBox is parented to the AdminFrame.)

Oh, that’s probably the way how you have your GUI Parented or something

You could just also simply change the TextBox’s Position property while Editing, and set it to where you want it if it’s parented inside the AdminFrame

1 Like

Oh and how do i do the same with setting the player’s speed?

Okay I’m here, what do you mean by doing the same with setting the player’s speed?

Verify what @Jackscarlett said in post 2. The same i want to do but this time changing the player’s speed.

Just to confirm, you’re wanting to change the speed of another player or just yourself?

I want to change the speed of me or another player.

EXAMPLE: In his LocalScript, once i lose focus on the TextBox, a RemoteEvent will fire and a Script will be executed in ServerScriptService.

Oh then you can change the speed via another RemoteEvent then. You can just make a RemoteEvent like previously and make it so once you lose focus on it, it fires it

local Event = game.ReplicatedStorage:WaitForChild("SpeedEvent")
local TextBox = script.Parent
local speedBox = --Textbox where you input speed

TextBox.FocusLost:Connect(function(PressedEnter)
    if PressedEnter then
        Event:FireServer(TextBox.Text,speedBox.Text) --This will be passed onto the server to receive 
    end
end)

Where SpeedEvent is the name of the RemoteEvent

Then you can just add t othe script with the former RemoteEvent

local speedEvent = game.ReplicatedStorage:WaitForChild("SpeedEvent")

speedEvent.OnServerEvent:Connect(function(PlayerWhoFired, TargetPlayer, Speed)
	local player = game:GetService("Players"):FindFirstChild(TargetPlayer)
	if not player or not player.Character then
		return
	end
	player.Character.Humanoid.WalkSpeed = Speed
end)

Can you give me a example of how do i fill this line, @EmbatTheHybrid ?

You just have to give it the Textbox where you type the speed to give

Ok I’m alive

Just create another TextBox parented where you want to place it

1 Like

like local speedBox = TextBox.Text?