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
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
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).
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
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
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.