Error within script?

Greetings, I am scripting an announcement system and the script has an error and is not fixing, no matter how hard I try.

image

local messaging = game:GetService("MessagingService")
local plr = game.Players.LocalPlayer

messaging:SubscribeAsync("Announcements", function(msg)
	print(msg.Data)
	print(msg.Send)
	game.ReplicatedStorage.ifSend.Value = true
	game.ReplicatedStorage.Receive:FireAllClients(msg.Data)
end)

game.ReplicatedStorage.sendAnnouncement.OnServerEvent:Connect(function(player, msg)
	for i,v in pairs do(plr:GetRankInGroup(9178694) >= 11)
		messaging:PublishAsync("Announcements")
	end
end)

1 Like

I think it’s :Getroleingroup not rank

1 Like

Pretty sure it’s :GetRankInGroup although I can try.

  • edit: Doesn’t work.

GetRankInGroup returns a number value, a for loop usually loops a table, what is this script designed to do?

1 Like

This script is supposed to fire the sendAnnouncement remote and receive it on the players screen, while making sure that rank 11 and above can only use it.

1 Like

Could you possibly try something like:

game.ReplicatedStorage.sendAnnouncement.OnServerEvent:Connect(function(player, msg)
    local rank = player:GetRankInGroup(9178694)
    if rank >= 11 then
        messaging:PublishAsync("Announcements")
    else
        warn("Your rank is not high enough to publish announcements!")
    end
end)
1 Like

I’ll try that now, I’ll update you when I insert it.

1 Like

It works. thank you! :slight_smile:

2 Likes

Glad I could help. My guess is that a for loop won’t work with number values. :smile:

1 Like