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

Trying to make a rank exclusive door, it won't work?

Basically, I'm trying to create a rank exclusive door. When the character touches the door, I want the property can collide to be false if they are a certain rank. It doesn't work, I know I'm doing something horribly wrong.

This is the error: GetRankInGroup is not a valid member of Part

(I feel annoyed with myself that I have to keep on asking questions on this site because of my poor script knowledge, I'm sorry but I don't want to use scripts online)

Script: Regular Script


function rank(player, hit)
if player:GetRankInGroup(4266272) == 0 then 
		script.Parent.CanCollide = true
	else 
		script.Parent.CanCollide = false
	end
end

script.Parent.Touched:connect(rank)

And if someone could properly explain services, get services and things like that (simply) that'd be great! I'm still learning about that, and no wiki site can explain it clearly enough for me.

1 comment

0

It’s Connect not connect.

2 answers

✓ Accepted answer

In your script you needed to get player from Touched use function :GetPlayerFromCharacter(examplefunction.Parent)

Example:

local PartTouch = script.Parent
local GroupID = 0
local RankID = 0

PartTouch.Touched:connect(function(plrhit)
	if plrhit.Parent:FindFirstChild("Humanoid") then
		local Player = game:GetService("Players"):GetPlayerFromCharacter(plrhit.Parent)
		if Player:GetRankInGroup(GroupID) >= RankID then
			PartTouch.CanCollide = false
			wait(1.5)
			PartTouch.CanCollide = true
		else
			PartTouch.CanCollide = true
		end
	end
end)

Also. CanCollide = true enables collision. use false

5 comments

0

It’s Connect not connect, stop giving OP deprecated code.

0

I'm using connect and this works. ;-;

0

No, it's connect.

0

I enabled collision because the rank 0 was a guest.. is there any way to do multiple ranks?

0

= using it means if player has rank 9 or higher it will work

game.Players:GetPlayerByCharacter(player) at the start of the function

1 comment

0

i mean GetPlayerFromCharacter***

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