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

What is " '<eof>' expected near 'local' " ??

i took this from Roblox Developer Hub And it say '' expected near 'local' line 34

-- Set up table to return to any script that requires this module script
local PlayerStatManager = {}
 
-- Table to hold player information for the current session
local sessionData = {}
 
local AUTOSAVE_INTERVAL = 60
 
-- Function that other scripts can call to change a player's stats
function PlayerStatManager:ChangeStat(player, statName, value)
	local playerUserId = "Player_" .. player.UserId
	assert(typeof(sessionData[playerUserId][statName]) == typeof(value), "ChangeStat error: types do not match")
	if typeof(sessionData[playerUserId][statName]) == "number" then
		sessionData[playerUserId][statName] = sessionData[playerUserId][statName] + value
	else
		sessionData[playerUserId][statName] = value
	end
end
 
-- Function to add player to the "sessionData" table
local function setupPlayerData(player)
	local playerUserId = "Player_" .. player.UserId
	sessionData[playerUserId] = {Money=0, Experience=0}
end
 
-- Connect "setupPlayerData()" function to "PlayerAdded" event
game.Players.PlayerAdded:Connect(setupPlayerData)
 
return PlayerStatManager

-- Function to add player to the "sessionData" table


local function setupPlayerData(player)
	local playerUserId = "Player_" .. player.UserId
	local data = playerData:GetAsync(playerUserId)
	if data then
		-- Data exists for this player
		sessionData[playerUserId] = data
	else
		-- Data store is working, but no current data for this player
		sessionData[playerUserId] = {Money=0, Experience=0}
	end
end
 
-- Connect "setupPlayerData()" function to "PlayerAdded" event
game.Players.PlayerAdded:Connect(setupPlayerData)

1 answer

You need to close your PlayerAdded event at line 27. It is expected to end a function after a return.

-- Connect "setupPlayerData()" function to "PlayerAdded" event
game.Players.PlayerAdded:Connect(setupPlayerData)

	return PlayerStatManager
end) -- You forgot this end.

-- Function to add player to the "sessionData" table

If you have any questions feel free to ask!

1 comment

0

it said " '' expected near 'end' "

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