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

How do I fix this IsInGroup is a nill value?

Asked by
knotam 3
5 years ago
Edited 5 years ago

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)

0
Error is on line 25 other parts work already. knotam 3 — 5y

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago

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)
0
Thanks for the help.. It works now. knotam 3 — 5y
0
np! starmaq 1290 — 5y
Ad

Answer this question