This script is not running properly, but it's not giving any errors

Hello, I’ve been making a Warning Command that is only usable to a certain rank.
But it’s not working properly nor giving errors.

local HttpService = game:GetService("HttpService")
local URL = " 
"

function sendDiscordMessage(DATA, name, picture)

	local info = {
		content = DATA,
		username = name,
		avatar_url = picture
	}

	local encoded = HttpService:JSONEncode(info)

	HttpService:PostAsync(URL, encoded)
end


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		print("Character is loaded, inserting WarningUI")
		local newUI = script.WarningGui:Clone()
		newUI.Parent = char
		newUI.Adornee = char.Head
	end)
	
	player.Chatted:Connect(function(message)
		local Message = message:split(" ")
		print("Message is splitted")
		
		if player:GetRankInGroup(7718106) >= 250 and message[1] == "/warn" then
			print("Player is allegible to use this command.")
			local playerName = Message[2]
			local toWarn = game.Players:FindFirstChild(playerName)
			local GUI = toWarn.Character.WarningGui
			local Value = GUI.Value
			
			Value.Value = Value.Value + 1
			GUI.Warnings.Text = "Warnings -"..Value.Value
			
			if Value.Value >= 5 then
				local DATA = "<@&884409417951498261>, <@&884409348649021451>. **@".. toWarn .."** is a troller or exploiter with Max Warnings, Please go and check it out."
				local imageUrl = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&Type=AvatarHeadShot&userId=" .. player.UserId
				local name = player.DisplayName .. " (@" .. player.Name .. ")"
				
				sendDiscordMessage(DATA, name, imageUrl)
			end
		end
	end)
end)

Please remove that url ASAP. Malicious users can use that to send messages to your server!

Treat it like a password. Only YOU should know it!

It’s a URL webhook so it can post on my discord server.

Oh i get what you mean, ill remove it right away.

Yes, I could use that to send messages to your server from my own studio because you did not hide the key.

Ok good. Now that it’s removed I can now examine the script lol

I think the issue is that you are using similar variable “Message” and “message”.

You used message[1] when you meant to use Message[1]. Consider changing it to another word, like Msg or MessageSplit

Try going into each if statement and do print(“test”) to see which one doesn’t work

Sorry, I replied so late. I’m on the road right now.

I already did, check the script to see.

Ok, which portion of the code isn’t printing anything and what is the script meant to do

After getting the rank from the player, it’s not printing anything after that.

Actually, this is probably way much more complicated than I can probably help with sorry, I just checked the code a second time and I don’t know much about urls tbh. I think though that there might be something messed up with your quotation marks, idk.

Probably there is something messed up with the Value variable cuz it is required for the next if statement that doesn’t work, try printing out the Value variable

I can’t test it out right now, I’m on the road.

Ok, neither can I, tell me later when you test it out.

1 Like

I fixed it, the problem was me using the wrong variable. Thank you for the help, I appreciated it!

1 Like