#Whats the best way to get the HumanoidRootParts Position or CFrame when the player leaves?
1 messages · Page 1 of 1 (latest)
what do you need the position for?
something where you spawn where you left type thing?
maybe a val that updates every 1 sec or a table that stores it
Very simple prob
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
What this a humanoid state?
I prob know this but I forgot
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
Ohhh
That fires when it’s leaving like the plr alr left
I think
Can’t store if ur not there
im prob wrong
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?
Idk I just get the tingles when I hear the word weld
yeah ur idea but
what would happen to the part after
It’s saved
just destroy it?
also there needs to be data store
*humane
of course
Yeah
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
From what I know
ServerScriptService
didnt work
i just used a server event
I don't know then, I'm sorry, I did it at school on my phone, I must have done it wrong.
did you try my idea or do you have something else that works?