01 | local DataStoreService = game:GetService( "DataStoreService" ) |
02 | local myDataStore = DataStoreService:GetDataStore( "myDataStore" ) |
03 |
04 | game.Players.PlayerAdded:Connect( function (player) |
05 | local char = player.Character or player.CharacterAdded:wait() |
06 | local ack = Instance.new( "IntValue" ) |
07 | ack.Name = "leaderstats" |
08 | local ack 2 = Instance.new( "IntValue" ) |
09 | ack 2. Name = "Stage" |
10 | ack 2. Value = 1 |
11 | ack 2. Parent = ack |
12 | ack.Parent = player |
13 | local ack 3 = Instance.new( "IntValue" , ack) |
14 | ack 3. Name = "Prestige" |
15 | ack 3. Value = 0 |
If a player has data they will spawn in the right place after dying once. If a player does not have data they will be on stage 0 and fall to their death infinitely.
On line 40: Attempt to index nil with 'CFrame'
local char = player.Character
That's what line 5 should be.
char:WaitForChild("HumanoidRootPart").CFrame = sl.CFrame + Vector3.new(0,3,0)
That's what line 40 should be.
01 | local DataStoreService = game:GetService( "DataStoreService" ) |
02 | local myDataStore = DataStoreService:GetDataStore( "myDataStore" ) |
03 |
04 | game.Players.PlayerAdded:Connect( function (player) |
05 | local char = player.Character or player.CharacterAdded:wait() |
06 | local ack = Instance.new( "IntValue" ) |
07 | ack.Name = "leaderstats" |
08 | local ack 2 = Instance.new( "IntValue" ) |
09 | ack 2. Name = "Stage" |
10 | ack 2. Value = 1 |
11 | ack 2. Parent = ack |
12 | ack.Parent = player |
13 | local ls = player.leaderstats |
14 | ls:WaitForChild( "Stage" ).Value = 1 |
15 | local ack 3 = Instance.new( "IntValue" , ack) |
This is the fixed code.