Why am I getting this error?

So I made a (Script) that teleports you to (tp) when touched (door) if rank in group is over 50, and it does work but every time on touch this (Error) comes in server why?

Error:

Script:


Thanks
Lucas :slightly_smiling_face:

Since you are using .Touched, it will register if anything touches it. Add a if statement at the top of your script to make sure its actually the Character touching it…

if Part.Parent:FirstFirstChild("Humnaoid") then
--Other stuff here
end
1 Like

It’s still not really working, now I’m just getting these errors

image

what should I do?

script:

Im not sure that those errors are from this script… But either way, the if statment should use :FindFirstChild() instead of :WaitForChild(). WaitForChild will literally pause the script until it finds it but FindFirstChild will return nil if its not there.

Can you include the Line Numbers on the script??

Last thing, theres a typo, Its “Humanoid” rather then “Humnaoid” my fault, accidentally misspelled it.

1 Like

I’m no longer getting any errors now it’s just not teleporting anymore on touch

Is the output displaying anything about it?

if not, it could just be the way that you are actually teleporting them.

Use this instead.

Part.Parent.Torso(OrHumanoidRootPart if r15).CFrame = TP.CFrame + Vector3.new(0,3,0)
1 Like

"Humanoid" is spelled wrong (was “Humnaoid”), and you don’t really need this in the first place anyway. You can just check if the player exists first before checking if they are in the group:

script.Parent.Touched:Connect(function(Part)
    local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
    if Player and Player:GetRankInGroup(GroupID) then
        if script.Parent.DoorInUse.Value == false then
            script.Parent.DoorInUse.Value = true
            Part.Parent:MoveTo(Tp.Position)
            script.Parent.DoorInUse.Value = false
        end
    end
end)
3 Likes

yep just saw thanks that fixed it

1 Like