Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I fix this IsInGroup is a nill value?

Keep getting IsInGroup a nill value heres the code, are you able to tell what i'm doing wrong? I was able to get it to work with hit but the type of game i'm making requires to it be click...

local rank = 1

local groupID = 4857556

  



  

clicked = false

waited = true

  

  

  

function onClicked(Clicker)

print(Clicker.Name)

if (Clicker.Name:IsInGroup(groupID) and Clicker.Name:GetRankInGroup(rank) >= rank) then

  

if clicked == true and waited == true

then

script.Parent.Transparency = 0

script.Parent.CanCollide = true

clicked = false

print("Clicked Close")

wait(0.1)

waited = false

end

  

  

  

if clicked == false and waited == true

then

script.Parent.Transparency = 0.5

script.Parent.CanCollide = false

clicked = true

end

wait(0.1)

waited = true

 
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment

0

Error is on line 25 other parts work already.

1 answer

✓ Accepted answer

You are doing Clicker.Name, which is a string of course. It would obviously error to do a_string:IsInGroup(). You would just need to change that to Clicked, which is the "Instance" that clicked. So the right thing is Instance:IsInGroup And that's also for the :GetRankInGroup

Another thing, in the :GetRankInGroup bit, your putting the rank as the paramater, while the paramater for that function should be the groupId so fix that.

local rank = 1

local groupID = 4857556

  

clicked = false

waited = true

  

function onClicked(Clicker)

print(Clicker.Name)

if (Clicker:IsInGroup(groupID) and Clicker:GetRankInGroup(groupID) >= rank) then

  

if clicked == true and waited == true

then

script.Parent.Transparency = 0

script.Parent.CanCollide = true

clicked = false

print("Clicked Close")

wait(0.1)

waited = false

end

  

  

  

if clicked == false and waited == true

then

script.Parent.Transparency = 0.5

script.Parent.CanCollide = false

clicked = true

end

wait(0.1)

waited = true

 
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

2 comments

0

Thanks for the help.. It works now.

0

np!

This discussion is preserved as it was. New answers, comments, and votes are closed.