Expected 'end' (to close 'then' at line 55), got <eof>; did you forget to close 'do' at line 98?
I am making a sword fighting game and I can't figure out how to fix it
here's the code
local dataStores = game:GetService("DataStoreService"):GetDataStore("BucksDataStore")
local defaultCash = 50
local playersLeft = 0
game.Players.PlayerAdded:Connect (function(player)
01 | playersLeft = playersLeft + 1 |
03 | local leaderstats = Instance.new( "Folder" ) |
04 | leaderstats.Name = "leaderstats" |
05 | leaderstats.Parent = player |
07 | local bucks = Instance.new( "IntValue" ) |
10 | bucks.Parent = leaderstats |
12 | local playerData = Instance.new( "Folder" ) |
13 | playerData.Name = player.Name |
14 | playerData.Parent = game.ServerStorage.PlayerData |
17 | local playerData = Instance.new( "StringValue" ) |
18 | equipped.Name = "Equipped" |
19 | equipped.Parent = playerData |
21 | local inventory = Instance.new( "Folder" ) |
22 | inventory.Name = "Inventory" |
23 | inventory.Parent = playerData |
25 | player.CharacterAdded:Connect( function (character) |
26 | character.Humanoid.WalkSpeed = 16 |
27 | character.Humanoid.Died:Connect( function () |
30 | if character.Humanoid and character.Humanoid:FindFirstChild( "creator" ) then |
31 | game.ReplicatedStorage.Status.Value = tostring (character.Humanoid.creator.Value).. " KILLED " ..player.Name |
33 | if character:FindFirstChild( "GameTag" ) then |
34 | character.GameTag:Destroy() |
37 | player:LoadCharacter() |
49 | if player_data ~ = nil then pcall ( function () |
50 | player_data = dataStores:GetAsync(player.UserId.. "-Bucks" ) |
53 | if player_data ~ = nil then pcall ( function () |
54 | weapons_data = dataStores:GetAsync(player.UserId.. "-Weps" ) |
57 | if player_data ~ = nil then pcall ( function () |
58 | eqipped_data = dataStores:GetAsync(player.UserId.. "-EquippedValue" ) |
61 | bucks.Value = player_data |
64 | bucks.Value = defaultCash |
end
local bindableEvent = Instance.new("BindableEvent")
game.Players.PlayerRemoving:Connect(function(player)
pcall(function()
dataStores:SetAsync(player.UserId.."-Bucks",player.leaderstats.Bucks.Value)
print("Saved")
playersLeft = playersLeft - 1
bindableEvent:Fire()
end)
end)
game:BindToClose(function()
-- This will be triggered upon shutdown
while playersLeft > 0 do
bindableEvent.Event:Wait()
end
end) <--------- where the error is