I would like to know how to make a admin console that I can write commands for example:
speed
kill
fling
fly
respawn
First Make a ScreenGui in StarterGui
in it Add a Frame
and in that Frame
Add TextBox
and TextButton
to it Just like this:
(You can add UICorne
r and UIStroke
to make Gui look Cool but it’s not necessary)
Heres how my Gui looks:
Now add a LocalScript in Frame
Scripting Part
We will start it by making a function
that detects specific Command and Value (In Number)
Local Script
local function DetectCommand(Text)
Text:lower()
if Text:find("Speed") then
local Value = string.match(Text, "(%d+)") -- Detecting Number Value from Text using string.match
game.ReplicatedStorage.RemoteEvent:FireServer("Speed", Value) -- Firing Remote Event with First Value of Command *"Speed"* and Second Value of Number
end
end
Now we have to make this function run when we click TextButton
script.Parent.TextButton.MouseButton1Click:Connect(function() -- When User Clicks TextButton
DetectCommand(script.Parent.TextBox.Text) -- Detects Text Entered in TextBox
end)
Over All LocalScript
local function DetectCommand(Text)
Text:lower()
if Text:find("Speed") then
local Value = string.match(Text, "(%d+)")
game.ReplicatedStorage.RemoteEvent:FireServer("Speed", Value)
end
end
script.Parent.TextButton.MouseButton1Click:Connect(function()
DetectCommand(script.Parent.TextBox.Text)
end)
Now we have to make a ServerScript
which checks for event when its runned
Create a ServerScript
in ServerScriptService
Server Script
We will first detect RemoteEvent
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, Command, Value) -- First Value **Player** is Recived automatically so we dont have to Fire it from LocalScript, Second Value is to detect Command, Third Value is to Detect Number
end)
Now we use detected command and value to make command work
Overall ServerScript
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, Command, Value)
if Command == "Speed" then -- if Command Received is Speed then we change Players Speed
Player.Character.Humanoid.WalkSpeed = Value -- Changing Player Speed to Value we Received from Command
end
end)
Now You know the basics of how it’s done.
You can use the same way and add more Commands for example:
LocalScript
local function DetectCommand(Text)
Text:lower()
if Text:find("Speed") then
print("Speed")
local Value = string.match(Text, "(%d+)")
game.ReplicatedStorage.RemoteEvent:FireServer("Speed", Value)
elseif Text:find("Jump") then
print("Jump")
local Value = string.match(Text, "(%d+)")
game.ReplicatedStorage.RemoteEvent:FireServer("Jump", Value)
end
end
script.Parent.TextButton.MouseButton1Click:Connect(function()
DetectCommand(script.Parent.TextBox.Text)
end)
ServerScript
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, Command, Value)
if Command == "Speed" then
print("Speed")
Player.Character.Humanoid.WalkSpeed = Value
elseif Command == "Jump" then
print("Jump")
Player.Character.Humanoid.JumpHeight = Value
end
end)
To Test Enter “Speed 100” in TextBox and Click Button, and it should make your character Speed 100
Make Sure Speed first letter S is capital, you can even make it detect both by doing this:
local function DetectCommand(Text)
Text:lower()
if Text:find("Speed") or Text:find("speed") then
print("Speed")
local Value = string.match(Text, "(%d+)")
game.ReplicatedStorage.RemoteEvent:FireServer("Speed", Value)
elseif Text:find("Jump") or Text:find("jump") then
print("Jump")
local Value = string.match(Text, "(%d+)")
game.ReplicatedStorage.RemoteEvent:FireServer("Jump", Value)
end
end
Change:
if Text:find("Speed") or Text:find("speed") then
and
elseif Text:find("Jump") or Text:find("jump") then
But Make sure when your firing it in event it has same sequence of letters,