So I'm trying to create a position saving/loading script but I keep running into errors
If I make the script like this:
game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) p.Character:moveTo(p:WaitForChild('leaderstats'):WaitForChild('LastLocation').Value) print('locationloaded') end) p.CharacterAdded:connect(function(c) repeat wait(0.5) p.leaderstats.LastLocation.Value = p.Character.HumanoidRootPart.Position print('locationsaved') until 1 == 0 end
I get the following error:
ServerScriptService.AutosavingLocation.PlayerJoined/PlayerLeft:12: ')' expected (to close '(' at line 6) near '<eof>'
Else if I add a ")" the end
game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) p.Character:moveTo(p:WaitForChild('leaderstats'):WaitForChild('LastLocation').Value) print('locationloaded') end) p.CharacterAdded:connect(function(c) repeat wait(0.5) p.leaderstats.LastLocation.Value = p.Character.HumanoidRootPart.Position print('locationsaved') until 1 == 0 end)
I get the following error:
ServerScriptService.AutosavingLocation.PlayerJoined/PlayerLeft:12: 'end' expected (to close 'function' at line 1) near '<eof>'
You are not closing the first function, add one more end) at the end of the script:
game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) p.Character:moveTo(p:WaitForChild('leaderstats'):WaitForChild('LastLocation').Value) print('locationloaded') end) p.CharacterAdded:connect(function(c) repeat wait(0.5) p.leaderstats.LastLocation.Value = p.Character.HumanoidRootPart.Position print('locationsaved') until 1 == 0 end) end)
Use indent (pressing Tab) to organize you Script lines to avoid issues like that.