I am attempting to script a door that lets only ranks above 20 in that group through.
ID=2606952 Part=script.Parent script.Parent.Touched:connect(onTouched) function onTouched(hit) if Part.Parent:FindFirstChild("Humanoid") then local Player=game.Players:GetPlayerFromCharacter(Part.Parent) if Player:IsInGroup(ID) then if Player:GroupRank(20) then script.Parent.CanCollide=false wait(0.1) script.Parent.CanCollide=true end end end end
It won't let through the rank 20. Also for letting every rank above 20 through what do I do? Do I have to list every rank above 20? Or can I tell it to allow every rank value above 20?
My original is terrible, but with help from drew1017 and KoreanBBQ I got this -
ID=2606952 part=script.Parent rank=player:GetRankInGroup(ID) part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then player=game.Players.GetPlayerFromCharacter(hit.Parent) if rank > 19 then part.CanCollide=false wait(1) part.CanCollide=true end end end)
but neither of theirs or this one works. What am I doing wrong? e.e
Erm, your arguments and all are kind of weird. Try this:
local ID=2606952 local part=script.Parent part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local plr=game.Players.GetPlayerFromCharacter(hit.Parent) if plr:RankInGroup(ID)>19 then part.CanCollide=false wait(0.1) part.CanCollide=true end end)
Please upvote if it works ;)
2 things: 1. GroupRank is not a method or property; In order to get what rank a player is you have to use GetRankInGroup(id of group) method on Player.
Something like this:
ID=2606952 Part=script.Parent script.Parent.Touched:connect(onTouched) function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then local Player=game.Players:GetPlayerFromCharacter(hit.Parent) if Player:IsInGroup(ID) then rank = Player:GetRankInGroup(ID) if rank >= 20 then script.Parent.CanCollide=false wait(0.1) script.Parent.CanCollide=true end end end end
(P.S. you dont have to use spaces for indenting, just use tab to indent)