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

?Vector3 is confused on behavior

Asked by 4 years ago

Hello. I'm trying to make an auto death teleporter but it's not working. It says Vector3 is not a valid member of Part and it just won't work.

local plr = game.Players.iiDkOffical
local character = plr.Character
character:WaitForChild("Humanoid").Died:Connect(function()
    local pos1 = character.HumanoidRootPart.Position
    plr:LoadCharacter()
    wait(0.11)
    character.HumanoidRootPart.Vector3 = Vector3.new(pos1)
end)
0
Try CFrame instead :b Block_manvn 395 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

you can't do HumanoidRootPart.Vector3.. I think you meant to do HumanoidRootPart.Position, which returns a Vector3

0
nope, butyou're getting there iiDkOffical 109 — 4y
0
How do you have 880 reputation while giving crap answers. incapaz 195 — 4y
2
"Vector3 is not a valid member of Part" means ur trying to index the property  Vector3 which is not defined on that object User#23252 26 — 4y
0
what do you mean crap answer? where are your great answers? and your high reputation? User#23252 26 — 4y
View all comments (5 more)
0
Low rep != low quality posts, my quality is pretty good bruh incapaz 195 — 4y
2
Uh, I can definitely back void_node when I can say that he is quite correct. Vector3 is a userdata type, not a property.... Using .Position will return the assigned Vector3 as he said, you need to cast a Vector3 datatype to Position to modify it. Ziffixture 6913 — 4y
0
ur just toxic.. shut up. User#23252 26 — 4y
0
Thanks @Feahren.. User#23252 26 — 4y
0
This is quite embarrassing for you two. Ziffixture 6913 — 4y
Ad
Log in to vote
0
Answered by
incapaz 195
4 years ago

The property for the position is Position, as you had it on line 4.

To make it work for all players, I would do it like this.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local connection
        connection = character.Humanoid.Died:Connect(function()
            local last_cf = character:GetPrimaryPartCFrame()
            player:LoadCharacter()
            wait(0.1)
            character:SetPrimaryPartCFrame(last_cf)
            connection:Disconnect()
        end)
    end)
end)

This also accounts for rotation. I also disconnect the connection when I am finished, to avoid a memory leak. A new connection will be remade, but only when they respawn.

0
didn't work iiDkOffical 109 — 4y
Log in to vote
0
Answered by 4 years ago

replace line 7 with character.HumanoidRootPart.Position = Vector3.new(pos1)

Answer this question