How do I make a brick kill you if you are lower than a certain rank?

I am writing a script where if you touch it then it will check to see if you are lower than a certain rank in a group and if you are lower than that rank in said group then it will kill you. The issue is that it just won’t kill you if you are lower then that rank. What I have tried so far is mixing together old scripts I have made and kill brick scripts but no matter what I do it isn’t working.

local Brick = script.Parent
local GROUPID = 32030352
local MIN_RANK = 255

local function PlayerTouched(Part)
	local Parent = Part.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		if game.Players:GetRankInGroup(GROUPID) < MIN_RANK then
			Parent.Humanoid.Health = 0
		end
	end
end

Brick.Touched:connect(PlayerTouched)
local Brick = script.Parent
local GROUPID = 32030352
local MIN_RANK = 255

local function PlayerTouched(Part)
	local Parent = Part.Parent
	local Player = game.Players:GetPlayerFromCharacter(Parent)
	if Player then
		if Player:GetRankInGroup(GROUPID) < MIN_RANK then
			Parent.Humanoid.Health = 0
		end
	end
end

Brick.Touched:connect(PlayerTouched)

game.Players is not the player object its where the player is stored. you were using game.Players:GetRankInGroup(GROUPID) which is incorrect.

3 Likes

Thank you so much it works now!!

1 Like

yea no problem its the small things that can mess up big time.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.