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

This wont Work, Help?!

script.Parent.DialogChoiceSelected:connect(function(choice, player)
        if player.GetRankInGroup (2672272) >= 2 then
            game.ServerStorage:findFirstChild(choice.Name)
            game.ServerStorage:findFirstChild(choice.Name):clone().Parent = workspace
		end
	end)

18:35:22.454 - GetRankInGroup is not a valid member of DialogChoice

1 answer

✓ Accepted answer

There are a few minor errors here:

script.Parent.DialogChoiceSelected:connect(function(player, choice)
	if player:GetRankInGroup(2672272) >= 2 then
		if game.ServerStorage:FindFirstChild(choice.Name) then
			game.ServerStorage[choice.Name]:Clone().Parent = workspace
		end
	end
end)

In the first line, you simply had the parameters backwards.

In the second line, GetRankInGroup is called as a method, not a function. This is true for I think every ROBLOX-provided function.

The third line uses the older (now technically deprecated) findFirstChild. In future code, use FindFirstChild instead. Same with clone vs. Clone.

Also in the third line, you aren't actually checking that it exists. If the FindFirstChild fails to find anything, it'll try to Clone that nothing anyway, producing an error. Needs an if statement.

And, finally, on the fourth line, you don't need to repeat the FindFirstChild, since it's known to already exist. Simply use brackets to directly access it.

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