So I'm making a command bar, and for example, I have a kill command. The commands are seen from the textbutton.
My name is Player, and I have this text in the textbutton: kill player
What I want to do: -Check if there is a name "Player" in the game (with the text being 'player', not 'Player') -Kill the player if there is
What I've tried:
local textbox = script.Parent local textbutton = script.Parent.ExecuteButton local FindPlayer = function(plr) local newplrs = game:GetService('Players'):GetPlayers() for _,n in pairs(newplrs) do if (string.lower(plr) == string.lower(n)) then return true end end end Kill = function(text) if (string.sub(text,1,5) == 'kill ') then local trgPlayer = FindPlayer(string.sub(text,6)) if trgPlayer and trgPlayer.Character then trgPlayer.Character:BreakJoints() end end end textbutton.MouseButton1Down:connect(function() Kill() end)
Any help would be appreciated.
With the player's name, use
string.lower()
on it, then when testing if the player is in game.Players use
string.lower()
on the objects in game.Players as well.