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

'<eof>' expected near 'end' what do i do?

Asked by
3wdo 198
5 years ago

i tried making my script into a data store but then it says on line 50 '<eof>' expected near 'end'

how do i fix this?

local data = game:GetService("DataStoreService")

local mineminemine = data:GetDataStore("mineminemine")


game.Players.PlayerAdded:Connect(function(player)
    local stats = Instance.new("Folder",player)
    stats.Name = "leaderstats"

    local cash = Instance.new("IntValue",stats)
    cash.Name = "Cash"
    cash.Value = 10

    local gold = Instance.new("IntValue",stats)
    gold.Name = "Gold"
    gold.Value = 0

    local data
    local succes, errormessage = pcall(function()
        data = mineminemine:SetAsync(player.UserId.."-cash")
    end)
    if succes then
        cash.Value = data
    else
        print("aww not loaded")
        warn(errormessage)  
    end
end)

    game.Players.PlayerRemoving:Connect(function(player)
        local succes, errormessage = pcall(function()
            mineminemine:SetAsync(player.UserId.."-cash",player.leaderstats.Cash.Value and player.leaderstats.Gold.Value)
        end)
        if succes then
            print("YES")
        else
            print("aww not save")
            warn(errormessage)
        end
    end)


    cash.Changed:Connect(function()
        if player.leaderstats.Cash.Value >= 10000 then
            player.leaderstats.Cash.Value = 0 -- Set the value = 0

            player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 1
        end
    end)
end)
0
maybe becuase there is two ends? Cynical_Innovation 595 — 5y
0
i will try 3wdo 198 — 5y
0
nope 3wdo 198 — 5y
0
hi see my answer royaltoe 5144 — 5y
View all comments (2 more)
0
Extra end on line 28 lolzmac 207 — 5y
0
<eof> means end of file (or in this case, your script) hiimgoodpack 2009 — 5y

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

You need to put your cash.Changed function inside player added and you needed to remove an end after this if statement:

  if succes then
        print("YES")
    else
        print("aww not save")
        warn(errormessage)
    end

entire script:

local data = game:GetService("DataStoreService")

local mineminemine = data:GetDataStore("mineminemine")


game.Players.PlayerAdded:Connect(function(player)
    local stats = Instance.new("Folder",player)
    stats.Name = "leaderstats"

    local cash = Instance.new("IntValue",stats)
    cash.Name = "Cash"
    cash.Value = 10

    local gold = Instance.new("IntValue",stats)
    gold.Name = "Gold"
    gold.Value = 0



    local data
    local succes, errormessage = pcall(function()
        data = mineminemine:SetAsync(player.UserId.."-cash")
    end)
    if succes then
        cash.Value = data
    else
        print("aww not loaded")
        warn(errormessage)  
    end

    cash.Changed:Connect(function()
        if player.leaderstats.Cash.Value >= 10000 then
            player.leaderstats.Cash.Value = 0 -- Set the value = 0
            player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 1
        end
    end)
end)

game.Players.PlayerRemoving:Connect(function(player)
    local succes, errormessage = pcall(function()
            mineminemine:SetAsync(player.UserId.."-cash",player.leaderstats.Cash.Value and player.leaderstats.Gold.Value)
    end)

    if succes then
        print("YES")
    else
        print("aww not save :( ")

    if(errormessage)then
            warn(errormessage)
    end
    end


end)


0
nice its working but its giving the error message "Argument 2 missing or nil" i will accept but i want to know if theres a way it can be fixed first 3wdo 198 — 5y
0
im helping someone else out ill look into it later. royaltoe 5144 — 5y
0
in 10-20 mins royaltoe 5144 — 5y
0
when you cilck the error message what script does it take you to? royaltoe 5144 — 5y
View all comments (3 more)
0
it takes me to line 28 3wdo 198 — 5y
0
errormessage is nil. it'll return an error message only if there is an error message royaltoe 5144 — 5y
0
check out my edit royaltoe 5144 — 5y
Ad

Answer this question