String Value Error?

I was trying to change the text on the admin output,it says

ServerScriptService.Admin – Put in SSS:33: attempt to call a string value

Here’s the script:

local rs = game:GetService("ReplicatedStorage")
local commandEvent = rs:FindFirstChild('CmdsPipe') or Instance.new("RemoteFunction", rs) commandEvent.Name = 'CmdsPipe'
local output = game.StarterGui.Admin2.Commands.Output

commandEvent.OnServerInvoke = function(player, command, target, value)
	if target then
		if target:lower() == 'me' then
			target = {player}
		elseif target:lower() == 'everyone' or target:lower() == 'all' then
			target = game.Players:GetChildren()
		elseif target:lower() == 'noobs' then
			target = game.Players:GetChildren()
			for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do
				for pos, plr in pairs(game.Players:GetChildren()) do
					if admin.Name == plr.Name then
						table.remove(target, pos)
					end
				end
			end
		else
			local Tplayer = game.Players:FindFirstChild(target)
			if Tplayer then
				target = {Tplayer}
			else
				print("target not found:", target)
				output.Text("target not found:", target)
				return false
			end
		end
	end
	
	print(player.Name, "executed", command, "on target", target)
	output.Text(player.Name, "executed", command, "on target", target)

Are you sure you defined that right? You should make the output.Text equal to a Value if it’s trying to define its property:

local rs = game:GetService("ReplicatedStorage")
local commandEvent = rs:FindFirstChild('CmdsPipe') or Instance.new("RemoteFunction", rs) commandEvent.Name = 'CmdsPipe'
local output = game.StarterGui.Admin2.Commands.Output

commandEvent.OnServerInvoke = function(player, command, target, value)
	if target then
		if target:lower() == 'me' then
			target = {player}
		elseif target:lower() == 'everyone' or target:lower() == 'all' then
			target = game.Players:GetChildren()
		elseif target:lower() == 'noobs' then
			target = game.Players:GetChildren()
			for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do
				for pos, plr in pairs(game.Players:GetChildren()) do
					if admin.Name == plr.Name then
						table.remove(target, pos)
					end
				end
			end
		else
			local Tplayer = game.Players:FindFirstChild(target)
			if Tplayer then
				target = {Tplayer}
			else
				print("target not found:", target)
				output.Text = "target not found:", target
				return false
			end
		end
	end
	
	print(player.Name, "executed", command, "on target", target)
	output.Text = player.Name, "executed", command, "on target", target
1 Like

Your right but I think It should be .. instead of , because that assigning 5 values to 1
So like this:

output.Text = player.. " executed ".. command.. " on target ".. target

But im not sure

1 Like

I was actually thinking about that, didn’t know if you could separate properties of a string using commas on variables but just on the safe side we’ll do it:

local rs = game:GetService("ReplicatedStorage")
local commandEvent = rs:FindFirstChild('CmdsPipe') or Instance.new("RemoteFunction", rs) commandEvent.Name = 'CmdsPipe'
local output = game.StarterGui.Admin2.Commands.Output

commandEvent.OnServerInvoke = function(player, command, target, value)
	if target then
		if target:lower() == 'me' then
			target = {player}
		elseif target:lower() == 'everyone' or target:lower() == 'all' then
			target = game.Players:GetChildren()
		elseif target:lower() == 'noobs' then
			target = game.Players:GetChildren()
			for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do
				for pos, plr in pairs(game.Players:GetChildren()) do
					if admin.Name == plr.Name then
						table.remove(target, pos)
					end
				end
			end
		else
			local Tplayer = game.Players:FindFirstChild(target)
			if Tplayer then
				target = {Tplayer}
			else
				print("target not found:", target)
				output.Text = "target not found: "..target
				return false
			end
		end
	end
	
	print(player.Name, "executed", command, "on target", target)
	output.Text = player.Name.." executed "..command.." on target "..target
1 Like

Will try this tmr,it’s 1am for me,TY for info,

ServerScriptService.Admin – Put in SSS:33: attempt to concatenate string with table

Try to do "target not found: "..target[1].Name instead of "target not found: "..target.

Just a few lines above, target was defined as a table (target = {Tplayer}), and you can cannot concatenate (..) strings with tables, therefore you get the first item in the table (which is Tplayer, an Instance) then get its Name or else it will error (attempt to concatenate string with Instance).

Doesn’t work(doesn’t change the output text) but no error message

What do you mean by “doesn’t change the output text”?

the ‘output.Text’ is suppose to change the textbox’s text to the output message(the one that we’re dealing with)

output.Text = "target not found: “…target
output.Text = player.Name…” executed “…command…” on target "…target

but it didn’t,there wasn’t an error message as well

Did you change it? target is table you can’t concatenate it.

My newest Script

local rs = game:GetService("ReplicatedStorage")
local commandEvent = rs:FindFirstChild('CmdsPipe') or Instance.new("RemoteFunction", rs) commandEvent.Name = 'CmdsPipe'
local output = game.StarterGui.Admin2.Commands.Output

commandEvent.OnServerInvoke = function(player, command, target, value)
	if target then
		if target:lower() == 'me' then
			target = {player}
		elseif target:lower() == 'everyone' or target:lower() == 'all' then
			target = game.Players:GetChildren()
		elseif target:lower() == 'noobs' then
			target = game.Players:GetChildren()
			for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do
				for pos, plr in pairs(game.Players:GetChildren()) do
					if admin.Name == plr.Name then
						table.remove(target, pos)
					end
				end
			end
		else
			local Tplayer = game.Players:FindFirstChild(target)
			if Tplayer then
				target = {Tplayer}
			else
				print("target not found:", target)
				output.Text = "target not found: "..target
				return false
			end
		end
	end

	print(player.Name, "executed", command, "on target", target)
	output.Text = player.Name.." executed "..command.." on target "..target

??? You did not change it? Of course it will not work.
I’ll update the script for you.

It should look something like this
local rs = game:GetService("ReplicatedStorage")
local commandEvent = rs:FindFirstChild('CmdsPipe') or Instance.new("RemoteFunction", rs) commandEvent.Name = 'CmdsPipe'
local output = game.StarterGui.Admin2.Commands.Output

commandEvent.OnServerInvoke = function(player, command, target, value)
	if target then
		if target:lower() == 'me' then
			target = {player}
		elseif target:lower() == 'everyone' or target:lower() == 'all' then
			target = game.Players:GetChildren()
		elseif target:lower() == 'noobs' then
			target = game.Players:GetChildren()
			for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do
				for pos, plr in pairs(game.Players:GetChildren()) do
					if admin.Name == plr.Name then
						table.remove(target, pos)
					end
				end
			end
		else
			local Tplayer = game.Players:FindFirstChild(target)
			if Tplayer then
				target = {Tplayer}
			else
				print("target not found:", target[1].Name)
				output.Text = "target not found: "..target[1].Name
				return false
			end
		end
	end

	print(player.Name, "executed", command, "on target", target[1].Name)
	output.Text = player.Name.." executed "..command.." on target "..target[1].Name

the script behind the line worked again!
but the output text still doesn’t change and that’s what I’m aiming for

Oh I know why.
local output = game.StarterGui.Admin2.Commands.Output.
You are not supposed to use game.StarterGui. Since this is a Server-sided script, you may not use game.Players.LocalPlayer.
game.StarterGui is only used for CoreGui related stuff. When a player’s character spawns in, the descendants of StarterGui and other Instances will be duplicated into the player.

Maybe this could work?
local rs = game:GetService("ReplicatedStorage")
local commandEvent = rs:FindFirstChild('CmdsPipe') or Instance.new("RemoteFunction", rs) commandEvent.Name = 'CmdsPipe'

commandEvent.OnServerInvoke = function(player, command, target, value)
    local output = player:WaitForChild("PlayerGui").Admin2.Commands.Output
	if target then
		if target:lower() == 'me' then
			target = {player}
		elseif target:lower() == 'everyone' or target:lower() == 'all' then
			target = game.Players:GetChildren()
		elseif target:lower() == 'noobs' then
			target = game.Players:GetChildren()
			for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do
				for pos, plr in pairs(game.Players:GetChildren()) do
					if admin.Name == plr.Name then
						table.remove(target, pos)
					end
				end
			end
		else
			local Tplayer = game.Players:FindFirstChild(target)
			if Tplayer then
				target = {Tplayer}
			else
				print("target not found:", target[1].Name)
				output.Text = "target not found: "..target[1].Name
				return false
			end
		end
	    print(player.Name, "executed", command, "on target", target[1].Name)
	    output.Text = player.Name.." executed "..command.." on target "..target[1].Name
	end

TY it worked!!!
This might get off-topic but…

It doesn't print and change the text to 'target not found' yet
print("target not found:", target[1].Name)
				output.Text = "target not found: "..target[1].Name
				return false

only the execute output works

EDIT:WOW the site crashed

Sorry for the late response. I think if TPlayer is found then it will not print it. It will only print if TPlayer is not found.

Then how to fix?
Script change?
Sorry for asking cause I don’t understand lol

I didn’t print as well when TPlayer is not found

Isn’t it intended? Since the only way to print it out is to have the target, but the value of target is not “me”, “all”, “everyone”, “noobs” or a Player’s Name. If there is no target, it will not print. If the value of target is one of the above, it still won’t print.