Help me activate my position save script?
Asked by
4 years ago Edited 4 years ago
I have these scripts here, and i want to activate them only by touching a part, so only if i touch a certain part the position saves.
first script:
1 | game.Players.PlayerAdded:Connect( function (player) |
2 | local val = player:WaitForChild( "Position" ) |
3 | player.CharacterAdded:connect( function (char) |
6 | val.Value = char:WaitForChild( "HumanoidRootPart" ).Position |
Second script:
01 | local ds = game:GetService( "DataStoreService" ) |
02 | local ds 1 = ds:GetDataStore( "PositionSAvingSystem" ) |
04 | game.Players.PlayerAdded:Connect( function (player) |
05 | local val = Instance.new( "Vector3Value" ,player) |
10 | userdata = ds 1 :GetAsync(player.UserId) |
14 | game.Workspace:WaitForChild(player.name):WaitForChild( "HumanoidRootPart" ).CFrame = CFrame.new(userdata.x, userdata.y, userdata.z) |
16 | ds 1 :SetAsync(player.UserId, { |
24 | game.Players.PlayerRemoving:Connect( function (player) |
25 | ds 1 :SetAsync(player.UserId, { |
26 | x = player.Position.Value.x, |
27 | y = player.Position.Value.y, |
28 | z = player.Position.Value.z |