What I’m trying to do should be fairly simple, but for some reason my code has been sadistically failing, and not achieving my academic goals that I am trying to reach.
local PS = game:GetService('Players')
local Msg= '/example kyler_josiah'
local Name=string.sub(msg,9,msg:len())--works(gets name)
local Plr = PS.Name-- doesn't work
And although I have tried many solutions, most ineffectually failed. Concluding that the best contender would be online.
Could you give some more information? I don’t really understand what you are trying to achieve. Is the ‘/example kyler_joshiah’ eventually gonna be used in a Chatted event?
You can use Player.Chatted, I suggest looking through the link I put.
Here is an example though
game.Players.PlayerAdded:Connect(function(player) -- Player is the player that was added
player.Chatted:Connect(function(msg) -- msg is the message sent
-- do stuff with msg and player
local Plr = player.Name -- Will work
end)
end)
Sadly i do not have any expierence with string.sub etc. Haven’t really learned it. But is this something ur looking for?
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg == '/example kyler_josiah' then
print(plr.Name)
end
end)
end)
local players = game:GetService("Players")
local message = "/example uwuCulturist"
local filteredMessage = string.split(message," ")
local playerName = filteredMessage[2]
local player = players:FindFirstChild(playerName)
if not player then
return warn(("Player '%s' not found"):format(playerName))
end
print(player)