My roblox script is being buggy with my PHP script

Console:


Script:

local admins = {
	"vq9o"
}
local key = "awfebgvwtqwq"
local website = "https://api.rampagestudios.org/lux/"
local service = game:GetService("HttpService")
local admin = function(player)
	for i,v in pairs(admins) do
		if player.Name == v or player.UserId == v then
			return true
		end
	end
end
-- Scripting PHP in my other tab...a
game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message == "/ban" or message == "/unban" then
			if admin(player) == true then
				player.PlayerGui.InsertedObjects.Admin.Visible = not player.PlayerGui.InsertedObjects.Admin.Visible
			else
				player:Kick("Nice Try!")
			end
		end
	end)
end)
game.ReplicatedStorage.Banish.OnServerEvent:Connect(function(player, userid, reason, action)
	if action == "check" then
		local data2 = {
			["target"] = userid,
			["reason"] = reason,
			["action"] = action,
			["authorization"] = key,
			["admin"] = player.UserId
		}
		local data service:JSONEncode(data2)
		local status = service:PostAsync("https://api.rampagestudios.org/lux/", data, Enum.HttpContentType.ApplicationJson, false)
		local feedback = service:JSONDecode(status)
		if feedback.status == 400 then
			player:Kick("LUX Nightclub \n You have been banned by " + feedback.admin + " for " + feedback.reason + ". You have been banned indefiently.")
		end
	end
	if action == "ban" or action == "unban" then
		if admin(player) == true then
			local data2 = {
				["target"] = userid,
				["reason"] = reason,
				["action"] = action,
				["authorization"] = key,
				["admin"] = player.UserId
			}
			local data service:JSONEncode(data2)
			local status = service:PostAsync("https://api.rampagestudios.org/lux/", data, Enum.HttpContentType.ApplicationJson, false)
			local feedback = service:JSONDecode(status)
			if feedback.status == 200 then
				if action == "ban" then
					player.PlayerGui.InsertedObjeccts.Admin.Status.Text = "jquery status: Player banned"
					game.Players:GetPlayerByUserId(userid):Kick("LUX Nightclub \n You have been banned by " + player.Name + " for " + reason + ". You have been banned indefiently.")
				end
				if action == "unban" then
					player.PlayerGui.InsertedObjeccts.Admin.Status.Text = "jquery status: Player unbanned"
				end
			end
			if feedback.status == 100 then
				if action == "ban" then
					player.PlayerGui.InsertedObjeccts.Admin.Status.Text = "jquery status: Player already banned"
				end
				if action == "unban" then
					player.PlayerGui.InsertedObjeccts.Admin.Status.Text = "jquery status: Player doesnt exist in LUX Systems"
				end
			end
			if feedback.status == 400 then
				player:Kick("LUX Nightclub \n You have been banned by " + feedback.admin + " for " + feedback.reason + ". You have been banned indefiently.")
			end
			if feedback.status == 300 then
				local data2 = {
					target = player.UserId,
					reason = "Exploiting",
					action = "ban",
					authorization = key,
					admin = 1
				}
				local data service:JSONEncode(data2)
				service(website, data, Enum.HttpContentType.ApplicationJson)
			end
		end
	else
		local data2 = {
			target = player.UserId,
			reason = "Exploiting",
			action = "ban",
			authorization = key,
			admin = 1
		}
		local data service:JSONEncode(data2)
		service(website, data, Enum.HttpContentType.ApplicationJson)
	end
end)

GUI:

script.Parent.Ban.MouseButton1Click:Connect(function()
	script.Parent.Action.Text = "Action: Ban"
end)
script.Parent.Unban.MouseButton1Click:Connect(function()
	script.Parent.Action.Text = "Action: Unban"
end)
script.Parent.Rap.MouseButton1Click:Connect(function()
	script.Parent.Action.Text = "Action: Requesting Ban History"
end)
script.Parent.Confirm.MouseButton1Click:Connect(function()
	if script.Parent.Action.Text == "Action: Ban" then
		game.ReplicatedStorage.Banish:FireServer(game.Players:GetUserIdFromNameAsync(script.Parent.Target.Text), script.Parent.Reason.Text, "ban")
	end
	if script.Parent.Action.Text == "Action: Unban" then
		game.ReplicatedStorage.Banish:FireServer(game.Players:GetUserIdFromNameAsync(script.Parent.Target.Text), script.Parent.Reason.Text, "unban")
	end
	if script.Parent.Action.Text == "Action: Requesting Ban History" then
		script.Parent.Action.Text = "Error. sorry, u can request ban historys yet."
	end
end)
1 Like

(API Key revoked. If your gonna message me about it)

Looks like it’s simply a typo on both line 35 and 51 causing it to error. You should change local data service:JSONEncode(data2) to local data = service:JSONEncode(data2).

The same typo also exists on line 82 and 94.

Hopefully that fixes it!

1 Like

As Jhxan mentions, the error states that data is nil. You just have to trace it back to where data is meant to be set and you can spot the typo.

Generally the error messages provide really useful clues to help debug, so read them carefully and go to the line it says the error occurs on. If there’s an issue with an argument (in this case, the second argument, i.e. data) then look into where that is set, and possibly add a print statement to check it’s value for yourself.

That’ll help you fix minor issues in the future much quicker :blush:

1 Like

I’m now getting this error.

(Sorry I was developing last night at 2am.)

That’s the same error - argument 2 is still nil. Can you show the accompanying code?

The other errors seem to be unrelated from a different script.