local function getProfile(player)
assert(Profiles[player], string.format("Profile does not exist for %s", player.UserId)) --Error happens here!
return Profiles[player]
end
PurchaseHandler script lines 16 - 23:
local player = OwnerValue.Value
if game.Players:FindFirstChild(player) then
if player ~= nil then
local tycoon = script.Parent.Name
print("The tycoon name: " ..tycoon)
PlayerDataHandler.loadTycoonData(player, tycoon)
end
end
I think special characters (at this case the percent) can cause different havoc, because they could have a purpose for other functions, like the " and ’ symbols.
I solved it finally! I made a newbie mistake by not actually setting the player and only going by that value. Basically I had a string value that showed who owns that tycoon and instead of setting the player from the players, i just didnt at all, so it couldnt find the userid.
you are referring to the value of OwnerValue at THE TIME YOU CREATE the variable. You could fix it by having it like this
if game.Players:FindFirstChild(OwnerValue.Value) then
local player = OwnerValue.Value
if player ~= nil then
local tycoon = script.Parent.Name
print("The tycoon name: " ..tycoon)
PlayerDataHandler.loadTycoonData(player, tycoon)
end
end
and then wrap the getProfile function into a conditional statement of the sort
if game.Players:FindFirstChild(OwnerValue.Value) then
local profile = getProfile(OwnerValue.Value)
end