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

Teleport giving me a some error I dont know why the error is there?

Trying to make a teleport, but the output says that the character is not a valid member of workspace.

local first = script.Parent.Part1
local sec = script.Parent.Part2



first.Touched:connect(function(hit)
    local hum = hit.Parent.Parent:FindFirstChild("Character")
     if hum ~= nil then
        hum.Torso.CFrame = sec.CFrame + Vector3.new(0,0,5)
    end


end)

1 answer

#What's your problem? The Character is located inside of workspace. Character.Parent is workspace not players. But Players.Character works because the property Character or Player is an ObjectValue. The same way ObjectValue.Value == part but part.Parent ~= ObjectValue.


#Final Product

local first = script.Parent.Part1
local sec = script.Parent.Part2

first.Touched:connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
     if hum then
        hum.Parent.Torso.CFrame = sec.CFrame:toWorldSpace(0,0,5)
    end
end)


Hope it helps!

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