Well, this question arose due to a problem,
What I wanted was basically when the player entered the game for the first time the script would define his status and clan based on his potential using a module script containing the statuses:
local plrData = {
NenCategory = "None",
Name = "None",
Age = 0,
Clan = "None",
Potential = 0,
Level = 0,
Speed = 28,
Strenght = 2,
Defense = 100,
}
return plrData
The Script that defines the statuses:
local badge = game:GetService("BadgeService")
local clans = require(game.ReplicatedStorage.Clans)
local plrData = require(game.ReplicatedStorage.plrData)
game.Players.PlayerAdded:Connect(function(player)
if not badge:UserHasBadgeAsync(player.UserId,4103466575919184) then
wait(10)
local clansChance= {
Zoldyck = 1,
Kurta = 0.1,
Freecs = 1,
Netero = 1,
Kreuger = 5,
Portor = 60,
Tsezguerra = 60,
Bordeau = 60,
Hatake = 60,
Magcub = 60,
Takano = 60,
Hazama = 60,
Todoroki = 60,
}
local nenCategory ={
Enhancer = 60,
Transmutation = 60,
Emission = 60,
Conjuration = 5,
Manipulation = 5,
Specialist = 0.1,
}
badge:AwardBadge(player.UserId,4103466575919184)
-- Montagem de status para o novo jogador:
--1* Definition of the player's Nen Type, What is his Nen category:
local luck = 0
for _,nenTypes in pairs(nenCategory) do
luck = luck + nenTypes
end
local function SetNenCategory()
local nenTypeValue = Random.new():NextNumber(0,luck)
for item,value in pairs(nenCategory) do
nenTypeValue = nenTypeValue - value
if nenTypeValue < 0 then
print(item)
return item
end
end
end
plrData.NenCategory = SetNenCategory()
print("Seu tuipo de nen é "..plrData.NenCategory.."!")
-- 2* Status Definition based on your Natural Potential, How fast the player will level up:
local events = game.ReplicatedStorage:WaitForChild("Events")
events.SetPlayerName.OnServerEvent:Connect(function(plr,plrName)
plrData.Name = plrName
print(plrData.Name)
events.SetPlayerName:FireClient(plr)
end)
events.SetPlayerAge.OnServerEvent:Connect(function(plr,plrAge)
plrData.Age = plrAge
print(plrData.Age)
events.SetPlayerAge:FireClient(plr)
end)
plrData.Potential = math.random(1,100)
plrData.Speed = plrData.Speed + (plrData.Potential/5)
plrData.Strenght = plrData.Strenght + (plrData.Potential/10)
plrData.Level = 1
plrData.Defense = plrData.Defense + (plrData.Potential/1)
--3* Clan Definition, Its Characteristics and Additional Status:
local sum = 0
for _,clans in pairs(clansChance) do
sum = sum + clans
end
local function SetPlayerClan()
local clanValue = Random.new():NextNumber(0,sum)
for item,value in pairs(clansChance) do
clanValue = clanValue - value
if clanValue < 0 then
print(item)
return item
end
end
end
plrData.Clan = SetPlayerClan()
print("Seu clan é ".. plrData.Clan.."!")
--4* Status Definition based on Player Clan:
if plrData.Clan == "freecs" then
plrData.Potential = plrData.Potential + clans.freecs.potential
print(plrData.Potential)
print(plrData.Clan)
plrData.Speed = plrData.Speed + clans.freecs.speed
plrData.Strenght = plrData.Strenght + clans.freecs.strenght
plrData.Defense = plrData.Defense + clans.freecs.defense
elseif plrData.Clan == "kreuger" then
plrData.Potential = plrData.Potential + clans.kreuger.potential
print(plrData.Clan)
plrData.Speed = plrData.Speed + clans.kreuger.speed
plrData.Strenght = plrData.Strenght + clans.kreuger.strenght
plrData.Defense = plrData.Defense + clans.kreuger.defense
elseif plrData.Clan == "netero" then
plrData.Potential = plrData.Potential + clans.kreuger.potential
print(plrData.Clan)
plrData.Speed = plrData.Speed + clans.netero.speed
plrData.Strenght = plrData.Strenght + clans.netero.strenght
plrData.Defense = plrData.Defense + clans.netero.defense
elseif plrData.Clan == "kurta" then
plrData.Potential = plrData.Potential + clans.kurta.potential
print(plrData.Potential)
print(plrData.Clan)
print("MINEIRO!")
plrData.Speed = plrData.Speed + clans.kurta.speed
plrData.Strenght = plrData.Strenght + clans.kurta.strenght
plrData.Defense = plrData.Defense + clans.kurta.defense
elseif plrData.Clan == "zoldyck" then
plrData.Potential = plrData.Potential + clans.zoldyck.potential
print("BAIANA!!!!")
print(plrData.Potential)
plrData.Speed = plrData.Speed + clans.zoldyck.speed
plrData.Strenght = plrData.Strenght + clans.zoldyck.strenght
plrData.Defense = plrData.Defense + clans.zoldyck.defense
end
end
print(plrData.Potential)
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
hum.WalkSpeed = plrData.Speed
hum.MaxHealth = plrData.Defense
hum.Health = plrData.Defense
print(plrData.Speed)
print(plrData.Defense)
print(plrData.Clan)
local finishedIntro = game.ReplicatedStorage:WaitForChild("Events"):WaitForChild("ReplicatePlrData")
finishedIntro.OnServerEvent:Connect(function(plr,name)
local plrInfo = player.PlayerGui:WaitForChild("PlayerBar"):WaitForChild("PlayerInfo")
plrInfo.Text = name.." "..plrData.Clan..",".. " "..plrData.Age..",".." ".. "Potential:".. " "..plrData.Potential
print("")
end)
end)
The problem is that when I tested this with my friend, the script set his statuses and those statuses replicated to me as well.
I took a look at data storage, but I don’t quite understand how I could use it in this case.
I hope for answers.