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

Got a weird error, how would I go about fixing this?

Asked by 9 years ago
-----Group 1----
GroupId = 921838
min = 1 
max = 255 
-----Group 2----
GroupId2 = -1 
min2 = -1 
max2 = -1
--Specific Settings-- 
Door = script.Parent 
Debounce = false 
local teleportto = game.Workspace.OutsideDoor
local location = {teleportto.Position}
local x = location[1].x
local y = location[1].y
local z = location[1].z
                                             ----------
                                             --Script--
                                             ---------- 
function Touched(Part)
    local Human = Part.Parent:findFirstChild("Humanoid")
        if Human ~= nil then
    print("Work")
if Debounce then return end
Debounce = true 
if Part.Parent then
    print("Work2")
        print("Work3.1")
if Human.Parent:GetRankInGroup(GroupId) >= min and Human.Parent:GetRankInGroup(GroupId) <= max or Human.Parent:GetRankInGroup(GroupId2) >= min2 and Human.Parent:GetRankInGroup(GroupId2) <= max2 then
    print("work4")
Human.Parent.Character.Torso.CFrame = CFrame.new(Vector3.new(x,y,z))
    print("Work5")
else
Part.Parent:breakJoints()
script.Parent.Denied:play()
end end end Debounce = false
Door.Touched:connect(Touched)

So what I am trying to do is make a new group only door, but this is the error I get. The parts that the player will get teleported are linked correctly. And what I mean by that is that they are in the right spot in the game explorer. The below answer did help but now a new error has arisen, sorry for the inconvenience and question asking. :( Any help is appreciated! :D

21:05:46.604 - GetRankInGroup is not a valid member of Model
21:05:46.606 - Script 'Workspace.Group Rank Only Door V1.5.1.Door.Group Rank Based', Line 29

2 answers

Log in to vote
1
Answered by 9 years ago

The problem here is that anything that touches the door can trigger the script. Imagine if a random part in the workspace touched the door. The script would index "human" as the part's parent' Humanoid. Obviously a random part wouldn't have a Humanoid, so "human" is indexed as nil (does not exist). So when the script uses the human variable it can't function since human is nil! To fix this, use an if statement.

function Touched(Part)
    local Human = Part.Parent:findFirstChild("Humanoid")
    if Human ~= nil then --If the humanoid exists then
0
That fixed a problem now a new one has arisen. And I dont ask questions often so please don't feel as I am just a punk who wants stuff done for them. I have been trying to finish this for 3 days now :( BinaryResolved 215 — 9y
0
No problem, you aren't a punk for asking questions! If you thought my answer helped you can upvote. I understand if you don't accept it since the other person solved your second problem. IcyArticunoX 355 — 9y
0
This still does not work same error BinaryResolved 215 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

Human.Parent is a character model in the Workspace. However, :GetRankInGroup() only works for the Player Instance under game.Players. So, perhaps something like this would work:

local plr = game.Players:GetPlayerFromCharacter(Human.Parent)
if plr:GetRankInGroup(GroupId) >= min and 
plr:GetRankInGroup(GroupId) <= max or
-- etc.

Notice how Human.Parent is replaced with plr, allowing you to get the player's rank in the group. Hope this helps :)

0
I will try this when i get home on my computer. BinaryResolved 215 — 9y

Answer this question