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)

5 comments
when i do that, my function calls underline yellow :(
It’s underlining red since all the syntax errors have been resolved. You’re now experiencing a logic problem with your code. You cannot call “player” outside of the PlayerAdded signal since it’s only passed as a parameter in it’s scope, making the CharacterAdded signal invalid. Same issue applies for saying character.Humanoid.Died.
Maybe give the link to the Alvin Blox Video so I can try to re-write the script for you.
oh here is the link https://www.youtube.com/watch?v=5AUP9C0rtBY