#Whats the best way to get the HumanoidRootParts Position or CFrame when the player leaves?

1 messages · Page 1 of 1 (latest)

proper ibex
#

:)

drifting flax
#

what do you need the position for?

#

something where you spawn where you left type thing?

fossil bison
#

Very simple prob

drifting flax
#

shouldnt we listen for characterRemoving and then store this value?

#

though idk if it works when the player leaves as i also had some problems there

#

i forgot how i fixed it

fossil bison
drifting flax
#

look

fossil bison
#

I prob know this but I forgot

drifting flax
#

local Players = game:GetServices(„Players“)
Players.PlayerRemoving:Connect(function(player)
player.CharacterRemoving:Connect(function(character)
— do stuff
end)
end)

#

something like that?

#

dw about my typos

fossil bison
#

Ohhh

#

That fires when it’s leaving like the plr alr left

#

I think

#

Can’t store if ur not there

#

im prob wrong

drifting flax
#

true

#

but we can weld a part to the HRP and parent it to the workspace

#

when player leaevs just get the parts position

#

that good?

fossil bison
#

yeah sure

#

or u can do
MY idea

drifting flax
#

but its

#

not very efficient?

#

though it would work

fossil bison
#

Idk I just get the tingles when I hear the word weld

drifting flax
#

weld

#

WeldConstraint

#

Motor6D

fossil bison
#

IGGJGJGJHHHJG

#

stoppppp

drifting flax
#

hehe

#

alright alright

fossil bison
#

yeah ur idea but

#

what would happen to the part after

#

It’s saved

#

just destroy it?

drifting flax
#

nah just save the position and then destroy the part

#

very humane (or smth)

fossil bison
#

also there needs to be data store

drifting flax
#

*humane

drifting flax
fossil bison
#

Ummm

#

Idk nonthose module data shenanigans and they prob don’t either

drifting flax
#

well they just asked what the best way for getting the position is

#

@proper ibex

fossil bison
#

OR

#

don’t do the idea at all and scrap allis

novel wind
#
local DataStoreService = game:GetService("DataStoreService")
local PositionStore = DataStoreService:GetDataStore("PlayerPositions")

game.Players.PlayerAdded:Connect(function(player)
    -- Try to load the saved position
    local savedPos = PositionStore:GetAsync(player.UserId)
    
    player.CharacterAdded:Connect(function(character)
        local hrp = character:WaitForChild("HumanoidRootPart")

        -- If a saved position exists, teleport the player
        if savedPos then
            hrp.CFrame = CFrame.new(savedPos.x, savedPos.y, savedPos.z)
        end
    end)
end)

game.Players.PlayerRemoving:Connect(function(player)
    local character = player.Character
    if character and character:FindFirstChild("HumanoidRootPart") then
        local pos = character.HumanoidRootPart.Position

        -- Save position
        PositionStore:SetAsync(player.UserId, {
            x = pos.X,
            y = pos.Y,
            z = pos.Z
        })
    end
end)
#

Roblox notifies the server one second before the player is leaving

proper ibex
#

i just used a server event

novel wind
#

I don't know then, I'm sorry, I did it at school on my phone, I must have done it wrong.

drifting flax