So I’m making a auto height/weight generation script for my game.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local DataStore2 = require(script.DataStore2)
DataStore2.Combine("DATA", "Wins")
DataStore2.Combine("DATA", "Losses")
DataStore2.Combine("DATA", "Bucks")
DataStore2.Combine("DATA", "Cosmetics")
DataStore2.Combine("DATA", "Slot1Biometrics")
DataStore2.Combine("DATA", "Slot1SkinTone")
DataStore2.Combine("DATA", "Slot1FightingStyle")
DataStore2.Combine("DATA", "Slot1Stats")
Players.PlayerAdded:Connect(function(player)
local WinStore = DataStore2("Wins", player)
local LossStore = DataStore2("Losses", player)
local BucksStore = DataStore2("Bucks", player)
local CosmeticStore = DataStore2("Cosmetics", player)
local Slot1BiometricStore = DataStore2("Slot1Biometrics", player)
local Slot1SkinTone = DataStore2("Slot1SkinTone", player)
local Slot1FightingStyle = DataStore2("Slot1FightingStyle", player)
local Slot1StatsStore = DataStore2("Slot1Stats", player)
local function GetWins(value)
ReplicatedStorage.PlayerDataStoreEvents.Wins:FireClient(player, value)
end
local function GetLosses(value)
ReplicatedStorage.PlayerDataStoreEvents.Losses:FireClient(player, value)
end
local function GetBucks(value)
ReplicatedStorage.PlayerDataStoreEvents.Bucks:FireClient(player, value)
end
local function GetCosmetics(value)
CosmeticStore:Set(value)
end
local function GetSlot1Biometrics(value)
Slot1BiometricStore:Set(value)
end
local function GetSlot1SkinTone(value)
Slot1SkinTone:Set(value)
end
local function GetSlot1FightingStyle(value)
Slot1FightingStyle:Set(value)
end
local function GetSlot1Stats(value)
Slot1StatsStore:Set(value)
end
GetWins(WinStore:Get())
GetLosses(LossStore:Get())
GetBucks(BucksStore:Get())
GetSlot1Biometrics({})
GetCosmetics({})
GetSlot1SkinTone({})
GetSlot1FightingStyle({})
GetSlot1Stats({})
CosmeticStore:OnUpdate(GetCosmetics)
Slot1FightingStyle:OnUpdate(GetSlot1FightingStyle)
Slot1BiometricStore:OnUpdate(GetSlot1Biometrics)
Slot1SkinTone:OnUpdate(GetSlot1SkinTone)
Slot1StatsStore:OnUpdate(GetSlot1Stats)
WinStore:OnUpdate(GetWins)
LossStore:OnUpdate(GetLosses)
BucksStore:OnUpdate(GetBucks)
end)
-- This is a RemoteEvent where a player can purchase a product by its name.
ReplicatedStorage.PlayerDataStoreEvents.BuyItem.OnServerEvent:Connect(function(player, HairName)
local Hair = game.ServerStorage.PlayerAccesories.Hair
local CosmeticStore = DataStore2("Cosmetics", player)
local PlayerCosmetics = CosmeticStore:Get()
if not Hair[HairName] then return end
local CosmeticStore = DataStore2("Cosmetics", player)
local BucksStore = DataStore2("Bucks", player)
local productPrice = Hair[HairName].Price.Value
if BucksStore:Get() >= productPrice and not PlayerCosmetics[HairName] then
print("Buying product", HairName)
BucksStore:Increment(-productPrice)
table.insert(CosmeticStore, Hair[HairName])
CosmeticStore:Set(PlayerCosmetics)
else
return false
end
end)
ReplicatedStorage.PlayerDataStoreEvents.ResetStatDebug.OnServerEvent:connect(function(plr)
local userDatastore = DataStore2("Slot1Biometrics", plr)
userDatastore:Set(nil)
end)
ReplicatedStorage.PlayerDataStoreEvents.Slot1Biometrics.OnServerEvent:Connect(function(player, character)
local MinimumHeight = 0.95
local HeightIncrement = 0.017
local MinimumWeight = 0.7
local WeightIncrement = 0.095
local BiometricStore = DataStore2("Slot1Biometrics", player)
local PlayerBiometrics = BiometricStore:Get({
Height = MinimumHeight + HeightIncrement * math.random(1, 12),
Weight = MinimumWeight + WeightIncrement * math.random(1, 3),
})
print(PlayerBiometrics.Height)
print(PlayerBiometrics.Weight)
local Humanoid = character:WaitForChild("Humanoid")
Humanoid:WaitForChild("BodyHeightScale").Value = PlayerBiometrics.Height
Humanoid:WaitForChild("BodyWidthScale").Value = PlayerBiometrics.Weight
Humanoid:WaitForChild("BodyDepthScale").Value = PlayerBiometrics.Weight
end)
ReplicatedStorage.PlayerDataStoreEvents.Slot1SkinTone.OnServerEvent:Connect(function(player, SkinTone)
local SkinToneStore = DataStore2("Slot1SkinTone", player)
local PlayerSkinTone = SkinToneStore:Get()
if not PlayerSkinTone then
player["Body Colors"].HeadColor = SkinTone
player["Body Colors"].LeftArmColor = SkinTone
player["Body Colors"].RightArmColor = SkinTone
player["Body Colors"].LeftLegColor = SkinTone
player["Body Colors"].RightLegColor = SkinTone
player["Body Colors"].TorsoColor = SkinTone
table.insert(SkinToneStore, SkinTone)
SkinToneStore:Set(PlayerSkinTone)
else
local SkinTone = SkinToneStore:Get(SkinTone)
player["Body Colors"].HeadColor = SkinTone
player["Body Colors"].LeftArmColor = SkinTone
player["Body Colors"].RightArmColor = SkinTone
player["Body Colors"].LeftLegColor = SkinTone
player["Body Colors"].RightLegColor = SkinTone
player["Body Colors"].TorsoColor = SkinTone
end
end)
ReplicatedStorage.PlayerDataStoreEvents.Slot1FightingStyle.OnServerEvent:Connect(function(player, FightingStyle)
local FightingStyleStore = DataStore2("Slot1FightingStyle", player)
local PlayerFightingStyle = FightingStyleStore:Get()
if not PlayerFightingStyle then
table.insert(FightingStyleStore, FightingStyle)
if FightingStyle == "Balanced" then
player.IntValues.StatCaps.PowerStatCap = 15
player.IntValues.StatCaps.SpeedStatCap = 15
player.IntValues.StatCaps.ChinStatCap = 15
player.IntValues.StatCaps.StaminaStatCap = 15
else if FightingStyle == "Boxer Puncher" then
player.IntValues.StatCaps.PowerStatCap = 12
player.IntValues.StatCaps.SpeedStatCap = 20
player.IntValues.StatCaps.ChinStatCap = 12
player.IntValues.StatCaps.StaminaStatCap = 20
else if FightingStyle == "Slugger" then
player.IntValues.StatCaps.PowerStatCap = 20
player.IntValues.StatCaps.SpeedStatCap = 13
player.IntValues.StatCaps.ChinStatCap = 20
player.IntValues.StatCaps.StaminaStatCap = 15
else if FightingStyle == "Inside Figther" then
player.IntValues.StatCaps.PowerStatCap = 18
player.IntValues.StatCaps.SpeedStatCap = 17
player.IntValues.StatCaps.ChinStatCap = 20
player.IntValues.StatCaps.StaminaStatCap = 10
else if FightingStyle == "Peakaboo" then
player.IntValues.StatCaps.PowerStatCap = 20
player.IntValues.StatCaps.SpeedStatCap = 18
player.IntValues.StatCap.ChinStatCap = 12
player.IntValues.StatCap.StaminaStatCap = 12
end
end
end
end
FightingStyleStore:Set(PlayerFightingStyle)
end
else
local FightingStyle = FightingStyleStore:Get(FightingStyle)
if FightingStyle == "Balanced" then
player.IntValues.StatCaps.PowerStatCap = 15
player.IntValues.StatCaps.SpeedStatCap = 15
player.IntValues.StatCaps.ChinStatCap = 15
player.IntValues.StatCaps.StaminaStatCap = 15
else if FightingStyle == "Boxer Puncher" then
player.IntValues.StatCaps.PowerStatCap = 12
player.IntValues.StatCaps.SpeedStatCap = 20
player.IntValues.StatCaps.ChinStatCap = 12
player.IntValues.StatCaps.StaminaStatCap = 20
else if FightingStyle == "Slugger" then
player.IntValues.StatCaps.PowerStatCap = 20
player.IntValues.StatCaps.SpeedStatCap = 13
player.IntValues.StatCaps.ChinStatCap = 20
player.IntValues.StatCaps.StaminaStatCap = 15
else if FightingStyle == "Inside Figther" then
player.IntValues.StatCaps.PowerStatCap = 20
player.IntValues.StatCaps.SpeedStatCap = 15
player.IntValues.StatCaps.ChinStatCap = 20
player.IntValues.StatCaps.StaminaStatCap = 10
else if FightingStyle == "Peakaboo" then
player.IntValues.StatCaps.PowerStatCap = 20
player.IntValues.StatCaps.SpeedStatCap = 18
player.IntValues.StatCap.ChinStatCap = 12
player.IntValues.StatCap.StaminaStatCap = 12
end
end
end
end
end
end
end)
ReplicatedStorage.PlayerDataStoreEvents.Slot1StatSet.OnServerEvent:Connect(function(player)
local StatsStore = DataStore2("Slot1Stats", player)
local PlayerStatsStore = StatsStore:Get()
local ChinStat = player.IntValues.Chin
local PowerStat = player.IntValues.Power
local SpeedStat = player.IntValues.Speed
local StaminaStat = player.IntValues.Stamina
if not PlayerStatsStore then
table.insert(PlayerStatsStore, ChinStat)
table.insert(PlayerStatsStore, PowerStat)
table.insert(PlayerStatsStore, SpeedStat)
table.insert(PlayerStatsStore, StaminaStat)
PlayerStatsStore:Set()
else
local SavedChinStat = PlayerStatsStore:Get(ChinStat)
local SavedPowerStat = PlayerStatsStore:Get(PowerStat)
local SavedSpeedStat = PlayerStatsStore:Get(SpeedStat)
local SavedStaminaStat = PlayerStatsStore:Get(StaminaStat)
ChinStat.Value = SavedChinStat.Value
PowerStat.Value = SavedPowerStat.Value
SpeedStat.Value = SavedSpeedStat.Value
StaminaStat = SavedStaminaStat.Value
end
end)
So, after some tinkering this is the script (pay attention to the biometric event). It creates the height/weight just fine but the issue is that it dosen’t save the height already generated and just keeps creating random heights. What I need it to do is create a random height/weight once, put in the datastore and then grab that height/weight. Now I’m wondering if it would be more effective to make a if statement or just make a whole new event dedicated to grabbing already saved heights. And I would test these on my own, however I don’t know how to see if the value is already in the store, thus why im editing this post. Thanks!