Why does my admin script only work in solo test?

The name discribes the problem.

local function Kit(Player)
	if typeof(Player) == "table" then
		for i, plr in pairs(Player) do

		end
	else

	end
end













local function Freeze(Player)
	if typeof(Player) == "table" then
		for i, plr in pairs(Player) do

			for i, obj in pairs(plr.Character:GetChildren()) do
				if obj:IsA ("BasePart") then
					obj.Anchored = true
				end
			end
			local Ice = Instance.new("Part")
			Ice.Anchored = true
			Ice.Transparency = 0.5
			Ice.CanCollide = false
			Ice.Parent = plr.Character
			Ice.CFrame = plr.Character.HumanoidRootPart.CFrame
			Ice.Orientation += Vector3.new(math.random(-10, 10), math.random(-10, 10),math.random(-10, 10))
			Ice.Size = Vector3.new(7, 10, 7)
			Ice.Material = Enum.Material.Ice --go to line 180


		end
	else
		for i, obj in pairs(Player.Character:GetChildren()) do
			if obj:IsA ("BasePart") then
				obj.Anchored = true
			end
		end
		local Ice = Instance.new("Part")
		Ice.Anchored = true
		Ice.Transparency = 0.5
		Ice.CanCollide = false
		Ice.Parent = Player.Character
		Ice.CFrame = Player.Character.HumanoidRootPart.CFrame
		Ice.Orientation += Vector3.new(math.random(-10, 10), math.random(-10, 10),math.random(-10, 10))
		Ice.Size = Vector3.new(7, 10, 7)
		Ice.Material = Enum.Material.Ice


	end
end





















local function Kill(Player)
	if typeof(Player) == "table" then
		for i, plr in pairs(Player) do
			plr.Character:FindFirstChildOfClass("Humanoid").Health = 0
		end
	else
		Player.Character:FindFirstChildOfClass("Humanoid").Health = 0
	end
end
local function Warp(Player, Client)
	if typeof(Player) == "table" then
		for i, plr in pairs(Player) do
			plr.Character:PivotTo(Client)
		end
	else
		Player.Character:PivotTo(Client)
	end
end

local function Kick(Player, Message)
	if typeof(Player) == "table" then
		for i, plr in pairs(Player) do
			plr:Kick(Message)
		end
	else
		Player:Kick(Message)
	end
end

local function cmds(Player)
	script.Parent.Parent.AdminFrame.Visible = true
end
local function cmdsClose(Player)
	script.Parent.Parent.AdminFrame.Visible = false
end

local function Glow(Player, One, Two, Three, Four, Five)
	if typeof(Player) == "table" then
		for i, plr in pairs(Player) do
			local Light = Instance.new("PointLight")
			Light.Brightness = Four
			Light.Range = Five
			Light.Color = Color3.new(One / 255, Two / 255, Three / 255)
			Light.Parent = plr.Character.HumanoidRootPart
		end
	else
		local Light = Instance.new("PointLight")
		Light.Brightness = Four
		Light.Range = Five
		Light.Color = Color3.new(tonumber(One) / 255, tonumber(Two / 255), tonumber(Three) / 255)
		Light.Parent = Player.Character.HumanoidRootPart
	end
end




local function FindPlayerFromSlightOffset(PlayerError)
	for I, V in pairs(game.Players:GetPlayers()) do
		if PlayerError:lower() == (V["Name"]:lower()):sub(1, #PlayerError) then
			return V 
		end 
	end
end

script.Parent.Parent.Events.ChangeScriptType.OnServerEvent:Connect(function(Client, Info, Type)
	if Type == "CommandsTesting" then
		local function CommandFire(Message)
			local IsCommand = false
			if string.match(Message[1], "^%s*(.)") == "!" then
				IsCommand = true
			end
			if IsCommand == true then
				local cmd1 = string.split(Message[1], "!")
				cmd1 = cmd1[2]
				if Message[2] ~= nil then
					cmd2 = FindPlayerFromSlightOffset(Message[2])
					cmd2 = nil
				end
				local cmd3 = Message[3]
				local cmd4 = Message[4]
				local cmd5 = Message[5]
				local cmd6 = Message[6]
				local cmd7 = Message[7]
				if Message[2] ~= nil then
					if Message[2]:lower() == "all" then
						cmd2 = game.Players:GetChildren()
					end
					if Message[2]:lower() == "me" then
						cmd2 = Client
					end
					if Message[2]:lower() == "others" or Message[2]:lower() == "other" then
						cmd2 = {}
						for i, plr in pairs(game.Players:GetPlayers()) do
							if plr ~= Client then
								table.insert(plr, cmd2)
							end
						end
					end
				end
				if string.lower(cmd1) == "kill" then
					Kill(cmd2)
				end

				if string.lower(cmd1) == "freeze" or string.lower(cmd1) == "ice" then
					Freeze(cmd2)
				end


				if string.lower(cmd1) == "cmds" then
					cmds()
				end
				if string.lower(cmd1) == "close" then
					cmdsClose()
				end
				if string.lower(cmd1) == "kick" then
					Kick(cmd2)--(=))))))))))))))))))))))))))))) screw
				end
				if string.lower(cmd1) == "warp" then
					Warp(cmd2, Client.Character.HumanoidRootPart.CFrame)--(=))))))))))))))))))))))))))))) screw
				end
				if string.lower(cmd1) == "light" or string.lower(cmd1) == "bright" or string.lower(cmd1) == "glow" then
					Glow(cmd2, cmd3, cmd4, cmd5, cmd6, cmd7)
				end
			end
		end

		Client.Chatted:Connect(function(Message)
			CommandFire(string.split(Message," "))
		end)
	end
end)

Since you’re listening for commands via the Client variable, can we have a look at that script firing FireServer?

Also why are there duplicates of functions and a bunch of empty lines?

local Chat = game.Players.LocalPlayer.Chatted
script.Parent.Parent.Events.ChangeScriptType:FireServer(Chat, “CommandsTesting”)

Wait… you know you can just use PlayerAdded right? You won’t even need to send a remoteEvent

Yes I will. It’s in the UI.

1 Like

Does that mean you’re gonna keep doing what you’re doing? If yeah then uh I’m not really sure sorry

1 Like