Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

HELP PLEASE MY SCRIPT HAS A ERROR AND I'M STUCK?

Asked by 4 years ago
Edited by Ziffixture 4 years ago

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)
0
1. Delete the ) (There would be more step if it still error) Nguyenlegiahung 1091 — 4y
0
when i do that, my function calls underline yellow :( SupaEpicDad 0 — 4y
0
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. Ziffixture 6913 — 4y
0
Maybe give the link to the Alvin Blox Video so I can try to re-write the script for you. JuzeyPlayz -83 — 4y

2 answers

Log in to vote
0
Answered by
JoneXI 51
4 years ago

I think that there has to be no ), just end.

0
when i do that all my function calls under line orange SupaEpicDad 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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) 
0
So it should still work with all the spaces if it dosent then just push them together but try it normal first. Also check ur Output in Studio when testing. JuzeyPlayz -83 — 4y

Answer this question