Im a Bad scripter and a Very beginner one, i was copying a Alvin Blox vid on yt and on line 43 of my code i had a error >:( it said expected identifer when parsing, got ')' on my end) i marked the error with ERROR --> Can You Anyone help?!?!
Script:
local dataStores = game:GetService("DataStoreService"):GetDataStore("CashDataStore") local defaultCash = 0 local playersLeft = 0 game.Players.PlayerAdded:Connect(function(player) playersLeft = playersLeft + 1 local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local bucks = Instance.new("IntValue") bucks.Name = "Cash" bucks.Value = 0 bucks.Parent = leaderstats end) player.CharacterAdded:Connect(function(character) character.Humaniod.WalkSpeed = 16 end) character.Humanoid.Died:Connect(function() if character:FindFirstChild("GameTag") then character.GameTag:Destroy() end player:LoadCharacter() end) local player_data pcall(function() player_data = dataStores:GetAsync(player.UserId.."-Cash") end) if player_data ~= nil then bucks.Value = player_data else bucks.Value = defualtCash ERROR HERE--> end) local bindableEvent = Instance.new("BindableEvent") game.Players.PlayerRemoving:Connect(function(player) pcall(function() dataStores:SetAsync(player.UserId.."-Cash", player.leaderstats.Cash.Value) print("Saved") playersLeft = playersLeft - 1 bindableEvent:Fire() end) end) game:BindToClose(function() while playersLeft > 0 do bindableEvent.Event:Wait() end end)
I think that there has to be no ), just end.
Here put this script from the video and see what goes on tell me if it worked. You can change Money to your currency like Cash I see you put that.
local player = game.Players.LocalPlayer local leaderstats = player:WaitForChild("leaderstats") local datastore = game:GetService("DataStoreService"):GetDataStore("MoneySave") local money = leaderstats:WaitForChild("Money") defaultCash = 10 playersLeft = 0 game.Players.PlayerAdded:Connect(function(player) playersLeft = playersLeft +1 local folder = Instance.new("Folder") folder.Parent = player folder.Name = "leaderstats" local money = Instance.new("IntValue") money.Parent = folder money.Name = "Money" end) local player_data pcall (function() player_data:GetAsync(player.UserId.."-Money") end) if player_data ~= nil then -- Load points in (player not new) money.Value = player_data else -- New Player money.value = defaultCash end local bindableEvent = Instance.new("BindableEvent") game.Players.PlayerRemoving:Connect(function() pcall (function() datastore:SetAsync(player.UserId.."-Money",player.leaderstats.Money.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)