Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

6 comments

0

maybe becuase there is two ends?

0

i will try

0

nope

0

hi see my answer

0

Extra end on line 28

0

means end of file (or in this case, your script)

1 answer

✓ Accepted answer

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)


7 comments

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

0

im helping someone else out ill look into it later.

0

in 10-20 mins

0

when you cilck the error message what script does it take you to?

0

it takes me to line 28

0

errormessage is nil. it'll return an error message only if there is an error message

0

check out my edit

This discussion is preserved as it was. New answers, comments, and votes are closed.