Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"Attempt to compare string and number" Help?

Asked by 4 years ago

Working on a gui that is cloned to your playerGui if you are at or above a certain group rank. After testing, this should work, but still isnt. Both of the values shown are number values. No values here are string. This is a serverScript that is in serverScriptService. My code:

1local groupId = script.GroupId.Value
2local minimumRank = script.MinimumRank.Value
3 
4game.Players.PlayerAdded:Connect(function(player)
5        if player:GetRoleInGroup(groupId) <= minimumRank then
6            local guiClone = script.Announce:Clone()
7            guiClone.Parent = player:WaitForChild("PlayerGui")
8        end
9end)

Any help would be appreciated.

1 answer

Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
4 years ago
Edited 4 years ago

Make sure it's GetRankInGroup, not GetRoleInGroup. Rank gives you the roleid, which is a number, role gives you the name of the role, which is a string.

1local groupId = script.GroupId.Value
2local minimumRank = script.MinimumRank.Value
3 
4game.Players.PlayerAdded:Connect(function(player)
5        if player:GetRankInGroup(groupId) <= minimumRank then
6            local guiClone = script.Announce:Clone()
7            guiClone.Parent = player:WaitForChild("PlayerGui")
8        end
9end)
0
Oh, thanks! AviaCheddar 41 — 4y
Ad

Answer this question