Hello! I need some help with a Command String.
I want it so when a Player Types in Chat “!Walkspeed” it will Enable the ScreenGUI. However, when I go In-Game, and type “!Walkspeed” nothing happens! So… I’m here for help. I think the 3rd or 2nd time today. Thanks for the help, AridOats.
Below is the Code used in a LocalScript, and is Inside the ScreenGUI:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:connect(function(msg)
if msg == "!Walkspeed" then
script.Parent.Enabled = true
end
end)
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:connect(function(msg)
if msg == "!Walkspeed" then
local PlayerGui = plr:WaitForChild('PlayerGui')
PlayerGui.YourGuiHere.Enabled = true
end
end)
end)
It isn’t that simple to make it happen.
The first problem is you are adding a playeradded event in a local script it won’t run because its local
–ServerScirpt
game.Players.PlayerAdded:Connect(function(plr)
local PlayerGui = plr:WaitForChild(“PlayerGui”)
plr.Chatted:connect(function(msg)
if msg == “!Walkspeed” then
PlayerGui.ScreenGui.Enabled = true
print(“Gui Enabled!”)
end
end)
end)
No I think because we are setting the gui enabled for the player who chatted not for everyone. If you wanted to you will need to fire a remotevent to all clients.
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg == "!Walkspeed" then
plr.PlayerGui.YourGUI.Enabled = true -- Grabs only the player that said it
end
end)
end)