[SOLVED] Username for short not cloning and the Admin being kicked as an exepction

Hello guys once for all, I found 2 issues.

  1. Usernames for short not cloning.
  2. Admin being kicked as an exception.

So, I tried to make an AdminPanel with the kick button, username, reason, username for short and the reason for short.

Usernames that are admins:

  • kdopdaux1803 (Me).
  • 4667Hp
  • LoukaTigre_ps3

These are all the users that have access to have an admin…

Recently, I made a Reason Click and it worked 1st try but with the users, nope.

LocalScript (1):

local usernameclick = script.Parent.Parent.Parent.Username

game.Players.PlayerAdded = script.Parent:Clone().Name
-- Put anything after: game.Players.PlayerAdded = script.Parent:Clone().Name + help me to fix: game.Players.PlayerAdded = script.Parent:Clone().Name (Sorry if it's the same one).

LocalScript (2(Before):

local username  = script.Parent.Parent.Username
local reason = script.Parent.Parent.Reason
local Player = game:GetService("Players").LocalPlayer
local exepct = {"kdopdaux1803","4667Hp","LoukaTigre_ps3"}

script.Parent.MouseButton1Click:Connect(function()
	if username.Text:gsub("%s", "") == "" then
		warn("You must supply a username before kicking.")
		return
	end
	if not game.Players:FindFirstChild(username.Text) then
		warn("There is no Player named \""..username.Text.."\" in the server!") 
		return
	end
	if game.Players:FindFirstChild(username.Text) then
		print("You kicked "..username.Text)
		game.ReplicatedStorage.KickPlayer:FireServer(username.Text, reason.Text)
		game.Players.LocalPlayer:Kick(reason.Text)
		if reason.Text == "" then
			game.Players.LocalPlayer:Kick("Unknow reason given.")
		else
			game.Players.LocalPlayer:Kick(reason.Text)
		end
	end
end)

LocalScript (2(After):

local username  = script.Parent.Parent.Username
local reason = script.Parent.Parent.Reason
local Player = game:GetService("Players").LocalPlayer
local exepct = {"kdopdaux1803","4667Hp","LoukaTigre_ps3"}

script.Parent.MouseButton1Click:Connect(function()
	if username.Text:gsub("%s", "") == "" then
		warn("You must supply a username before kicking.")
		return
	end
	if not game.Players:FindFirstChild(username.Text) then
		warn("There is no Player named \""..username.Text.."\" in the server!") 
		return
	end
	if game.Players:FindFirstChild(username.Text) then
		print("You kicked "..username.Text.." for "..reason.Text or "an unknow reason given")
		game.ReplicatedStorage.KickPlayer:FireServer(username.Text, reason.Text)
		game.Players.LocalPlayer:Kick(reason.Text)
		if reason.Text == "" then
			game.Players.LocalPlayer:Kick("Unknow reason given.")
		else
			game.Players.LocalPlayer:Kick(reason.Text)
		end
	end
	for i,v in pairs(exepct) do
		-- Add anythnig in here !
	end
end)

-- Starting to here, the Admins can be kicked.
if exepct == true then
	script.Parent.Parent["Username for short"].Username.Visible = false
end

Warning, it’s a different script then the other one

Videos:

Bug of the issue:

So yeah guys any help is appreciated.

The 1st one you have to reload the full script or add lines + fix the issue and the 2nd one, you have to add stuff on it.

since this a localscript, you don’t have to use game.Players.PlayerAdded event, cuz localscripts are already executed when the player joins the game.

Rip, instead it just had to errors me because it’s not in a function call :slightly_frowning_face:.

you can get the player in a local script by doing game.Players.LocalPlayer

13:59:45.749 Unable to assign property LocalPlayer. Object expected, got string - Client - LocalScript:3
13:59:45.749 Stack Begin - Studio
13:59:45.749 Script ‘Players.kdopdaux1803.PlayerGui.AdminPanel.OpenTheMenu.KickFrame.Username for short.Username.LocalScript’, Line 3 - Studio - LocalScript:3
13:59:45.750 Stack End - Studio

what are you exactly trying to do in this line? game.Players.PlayerAdded = script.Parent:Clone().Name

2 Likes

A Username for short to my Admin Panel…

if you want to get player’s username just do game.Players.LocalPlayer.Name

Okay, i’ll try that.

Char limit

It was a pretty good option but unfortunately, i don’t know how does did not worked.

14:03:47.973 The current identity (2) cannot set a Player’s name (lacking permission 4) - Client - LocalScript:3
14:03:47.973 Stack Begin - Studio
14:03:47.973 Script ‘Players.kdopdaux1803.PlayerGui.AdminPanel.OpenTheMenu.KickFrame.Username for short.Username.LocalScript’, Line 3 - Studio - LocalScript:3
14:03:47.973 Stack End - Studio

if you want your admin panel to have the local player username it should look like this

local Player = game.Players.LocalPlayer
local TextLabel = -- TextLabel Spot
TextLabel.Text = Player.Name

There’s no TextLabel, unfortunately…

then what do you want the playerName for?

The Username for short with a script but if a player joins, the user of it is visible…

here’s how you can check if a textbox isn’t empty & contains a string

local TextBox = script.Parent.Parent.TextBox -- Example
local TextButton = script.Parent -- Example

TextButton.MouseButton1Click:Connect(function()

local NoSpacesNEmptyCheck = string.gsub(TextButton.Text,"[%s]","")

if #NoSpacesNEmptyCheck > 0 then

local StringCheck = tostring(TextButton.Text)

if StringCheck then
-- stuff
end
end
end)
1 Like

Your script has 2 errors and 2 warnings.

show me the output. [Char Limit]

It’s called the Script Analysis for me.

Here’s the image:

bandicam 2022-07-28 14-43-03-490

yeah i fixed it [Char Limit Again]

It errored me because you didn’t got enough to the TextBox at the 1st line.