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

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

Asked by 8 years ago

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

Log in to vote
3
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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)
Ad

Answer this question