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

Why won't this onclick clothes giver work?

Asked by 4 years ago
01local Pants = script.Pants
02local Shirt = script.Shirt
03 
04local GroupID = 6763603 -- Group id here
05 
06script.Parent.ClickDetector.MouseClick:connect(function(Player)
07    if not Player:IsInGroup(GroupID) then return end
08    if Player:GetRoleInGroup(GroupID) < 50 then return end
09    local Character = Player.Character
10    if Character == nil then return end
11 
12    -- Get new shirt
13    local CharacterShirt = Character:findFirstChild("Shirt")
14    if CharacterShirt then CharacterShirt:Destroy() end
15    Shirt:Clone().Parent = Character
View all 21 lines...

In the output it say's "Workspace.Part.Script:8: attempt to compare string and number"

1 answer

Log in to vote
0
Answered by 4 years ago

The reason why your script won't work is actually very simple, by doing Player:GetRoleInGroup it would print out the name of the role they have in the group, if you wanted to get the number corresponding to their role, you would do :GetRankInGroup. If you take this into account, the script would look like this.

01local Pants = script.Pants
02local Shirt = script.Shirt
03 
04local GroupID = 6763603 -- Group id here
05 
06script.Parent.ClickDetector.MouseClick:connect(function(Player)
07    if not Player:IsInGroup(GroupID) then return end
08    if Player:GetRankInGroup(GroupID) < 50 then return end
09    local Character = Player.Character
10    if Character == nil then return end
11 
12    -- Get new shirt
13    local CharacterShirt = Character:findFirstChild("Shirt")
14    if CharacterShirt then CharacterShirt:Destroy() end
15    Shirt:Clone().Parent = Character
View all 21 lines...
0
Thank's alot this solved my problem, but any clue how to add more than role id? Asherharding10 12 — 4y
0
If you could help that would be nice :) Asherharding10 12 — 4y
Ad

Answer this question