How do I make it so you only have to type a few letters of a name and also that it doesnt matter if its capital or not

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? How do I make it so you only have to type a few letters of a player name and also that it doesn’t matter if it’s capitalized or not.

  2. What is the issue? The same as what I want to achieve.

  3. What solutions have you tried so far? I checked the developer hub and tried to do it on my own but no luck.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local remote = game.ReplicatedStorage.StartGameEvent
local serverstorage = game:GetService("ServerStorage")
remote.OnServerEvent:Connect(function(host, player1, player2)
	local platform = serverstorage.Platform:Clone()
	platform.Parent = game.Workspace.Debris
	print(player1)
	print(player2)
	local char1 = game.Workspace:FindFirstChild(player1)
	local char2 = game.Workspace:FindFirstChild(player2)
	print(char1)
	print(char2)

	char1:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0, 10, 0)))
	char2:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0, 10, 0)))
	local dat = game.ServerStorage.PlayerData
	dat.PLAYER1.Value = player1
	dat.PLAYER2.Value = player2
end)
local GetPlayer = function(Name)
	for i,v in pairs(game:GetService("Players"):GetChildren()) do
		if (string.sub(string.lower(v.Name),1,string.len(Name))) == string.lower(Name) then
			return v
		end
	end
end

1 Like

doesnt really help me with incorperating it into the script you see :confused:

To make it so that the player only has to type a few letters of a name and it doesn’t matter if it’s capital or not, you can use the string.lower() method to convert the player’s input to lowercase and then use the string.find() method to search for a substring within the player’s name. Here’s an example:

local playerInput = "PlaYer1"
local playerName = "Player1"

if string.find(string.lower(playerName), string.lower(playerInput)) then
  print("Player found!")
else
  print("Player not found.")
end

This will output “Player found!” because the string.find() method returns the index at which the substring was found. If the substring was not found, it will return nil .

You can use this in your code like this:

local remote = game.ReplicatedStorage.StartGameEvent
local serverstorage = game:GetService("ServerStorage")

remote.OnServerEvent:Connect(function(host, player1, player2)
  local platform = serverstorage.Platform:Clone()
  platform.Parent = game.Workspace.Debris
  
  -- Convert player names to lowercase for comparison
  player1 = string.lower(player1)
  player2 = string.lower(player2)

  local char1 = game.Workspace:FindFirstChild(player1)
  local char2 = game.Workspace:FindFirstChild(player2)

  if char1 and char2 then
    char1:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0, 10, 0)))
    char2:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0, 10, 0)))

    local dat = game.ServerStorage.PlayerData
    dat.PLAYER1.Value = player1
    dat.PLAYER2.Value = player2
  else
    print("One or both players not found.")
  end
end)

This will convert the player names to lowercase before searching for them in the workspace. It will also check if the characters were found before setting their primary part CFrame and player data.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.