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

Expected end when closing function got <eof>?

At first my ends worked perfectly and suddenly they broke. It is in a regular script. Here is my script(it's from an AlvinBlox tutorial bc i suck at stats):

local serverStorage = game:GetService("ServerStorage")
local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerSaveData")

game.Players.PlayerAdded:Connect(function(player)
	
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local strength = Instance.new("NumberValue")
	strength.Name = "Strength"
	strength.Parent = leaderstats
	
	local rebirths = Instance.new("IntValue")
	rebirths.Name = "Rebirths"
	rebirths.Parent = leaderstats
	
	local dataFolder = Instance.new("Folder")
	dataFolder.Name = player.Name
	dataFolder.Parent = serverStorage.RemoteData
	
	local debounce = Instance.new("BoolValue")
	debounce.Name = "Debounce"
	debounce.Parent = dataFolder

	local strengthData, rebirthsData
	
	local success,errormessage = pcall(function()
		strengthData = DataStore:GetAsync("strength-"..player.UserId)
		rebirthsData = DataStore:GetAsync("rebirths-"..player.UserId)
		
	if success then
		if strengthData then
			strength.Value = strengthData
			rebirths.Value = rebirthsData
		end	
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local success, errormessage = pcall(function()
		DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Strength.Value)
		DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Strength.Value)
	end)
end)

1 answer

✓ Accepted answer

Hey!

Try this. I added two ends one with a ) and one without it.

game.Players.PlayerAdded:Connect(function(player)


    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local strength = Instance.new("NumberValue")
    strength.Name = "Strength"
    strength.Parent = leaderstats

    local rebirths = Instance.new("IntValue")
    rebirths.Name = "Rebirths"
    rebirths.Parent = leaderstats

    local dataFolder = Instance.new("Folder")
    dataFolder.Name = player.Name
    dataFolder.Parent = serverStorage.RemoteData

    local debounce = Instance.new("BoolValue")
    debounce.Name = "Debounce"
    debounce.Parent = dataFolder

    local strengthData, rebirthsData

    local success,errormessage = pcall(function()
        strengthData = DataStore:GetAsync("strength-"..player.UserId)
        rebirthsData = DataStore:GetAsync("rebirths-"..player.UserId)
    end)

    if success then
        strength.Value = strengthData
        rebirths.Value = rebirthsData
   end
end)

6 comments

0

thanks for trying to help but it didn't work. I've tried so many combinations and still get and error. If you need it, here is the error message I received when doing that: Error: (38,5) Expected identifier when parsing expression, got ')'

0

try now. that font bit wasnt supposed to be there

0

I made a edit to the script, try it now

0

ugh still wont work

0

add me on Discord xWhiteHat#4788

0

k i did

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