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

"GetRankInGroup is not a valid member of Model" and math help?

So. I'm trying to get a damage script where you hit a brick, but if you are in a group with a certain rank or you've got a certain name, you aren't damaged, but if you aren't, you get a 5 damage. But I keep getting errors with the "GetRankInGroup" part..

local Auth = {
	["TheHospitalDev"] = true,
	["MrOwls"] = true,
	["Player"] = true,
	["Player1"] = true
}
local g = 2711620
local r = 252
local Damage = 5
script.Parent.Touched:connect(function(hit)

	print(hit.Name)
	if hit.Parent.Name[Auth] or hit.Parent:GetRankInGroup(g) >= r then
		print("Safe")
	else
		hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - Damage --Not sure if I subtracted correctly
		print("Damaged by:  "..Damage)
	end
end)
Left Leg -- Part that touches
23:02:10.049 - GetRankInGroup is not a valid member of Model
23:02:10.049 - Script 'Workspace.Union.Script', Line 13
23:02:10.051 - Stack End

1 answer

✓ Accepted answer

You're trying to get the character's rank in the group, when you should be getting the player's. Also, I'm not sure you're getting the characters

local Auth = { -- This is how I'd prefer doing it
    "TheHospitalDev",
    "MrOwls",
    "Player",
    "Player1",
}
local g = 2711620
local r = 252
local Damage = 5

script.Parent.Touched:connect(function(hit)
	print(hit.Name)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then -- Check if there's a humanoid first
		local inAuth = false
		for _, v in pairs (Auth) do
			if v.Name == hit.Parent.Name then
				inAuth = true
				break
			end
		end
	
		if inAuth or game.Players:GetPlayerFromCharacter(hit.Parent):GetRankInGroup(g) >= r then
			print("Safe")
		else
			hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - Damage --You did.
			print("Damaged by:  "..Damage)
		 end
	end
end)

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