hey, I was just learning how to script a murder game from roblox u, and the mydata isn't working for me, from an error I can't solve. Here is the script part I have, and The error message is at the bottom.

function playeradded(player)
	local leaderstats = Instance.new("IntValue")
	leaderstats.Name = "leaderstats"
	
	local credits = Instance.new("IntValue")
	credits.Name = "Credits"
	credits.Value = mydata.credits
	credits.Parent = player
	
	local multiplier = Instance.new("IntValue")
	multiplier.Name = "Multiplier"
	multiplier.Value = mydata.multiplier
	multiplier.Parent = player
	
	local laserknife = Instance.new("IntValue")
	laserknife.Name = "LaserKnife"
	laserknife.Value = mydata.laserknife
	laserknife.Parent = player
	
	local score = Instance.new("IntValue")
	score.Name = "Score"
	score.Value = mydata.score
	score.Parent = leaderstats
	
	local mydata = datastore:GetAsync(player.userId) or {}
	mydata.credits = mydata.credits or 0
	mydata.score = mydata.score or 0
	mydata.multiplier = mydata.multiplier or 1
	mydata.laserknife = mydata.laserknife or 0
	mydata.boomblade = mydata.boomblade or 0
	
	playerdata = {player.userId} = mydata
	
	leaderstats.Parent = player

error message: 15:06:23.578 - ServerScriptService.TKK_MAINSCRIPT:167: unexpected symbol near '='

Line 167 is: playerdata = {player.userId} = mydata

I can't seem to fix the error, does anyone have suggestions?

2 comments

0

I don't know what you expect that to do, or why you expect that to work.

0

@eLunate im trying to make this so mydata would save. Instead this error pops up.