RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create a script that saves players position that won’t make players fall of map"
-- Local script local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoidRootPart = character:WaitForChild("HumanoidRootPart") local function savePosition() local savedPosition = humanoidRootPart.Position game:GetService("DataStoreService"):GetDataStore("PlayerPositions"):SetAsync(player.UserId, savedPosition) end local function loadPosition() local savedPosition = game:GetService("DataStoreService"):GetDataStore("PlayerPositions"):GetAsync(player.UserId) if savedPosition then local newY = workspace.Baseplate.Size.Y/2 + 5 if savedPosition.Y < newY then savedPosition = Vector3.new(savedPosition.X, newY, savedPosition.Z) end humanoidRootPart.CFrame = CFrame.new(savedPosition) end end player.CharacterAdded:Connect(function(character) humanoidRootPart = character:WaitForChild("HumanoidRootPart") loadPosition() end) game:BindToClose(function() savePosition() end)