function OnPlayerAdded(Player)
Player:WaitForDataReady()
Player = game.Players.LocalPlayer
	Magic = Instance.new("StringValue", Player)
	Magic.Name = "Magic"
	if Player:LoadString("Magic") ~= "" then
		Magic.Value = Player:LoadString("Magic")
	else
		Elements = {"Water", "Fire", "Earth"}
		i = math.random(1, #Elements)
		Player.Magic.Value = Elements[i]
		Player:SaveString("Magic" , Player.Magic.Value)
		M = Instance.new("Message", workspace)
		M.Text = Magic.Value
		game.Debris:AddItem(M, 5)
	end
	if Player.Magic.Value == "Fire" then
		x = game.Lighting.Fireball:clone()
	elseif Player.Magic.Value == "Water" then
		x = game.Lighting.Waterball:clone()
	elseif Player.Magic.Value == "Earth" then
		x = game.Lighting.Rockball:clone()
	end
	x.Parent = Player.Backpack
end

game.Players.PlayerAdded:connect(OnPlayerAdded)

The script choses a ramdom magic from the table and saves using data store but its not working.

1 comment

0

Don't post duplicates of your questions. It's against the rules.