Any help would be very appreciated
BackStory
Im trying to create a sprinting script. Which when pressed ctrl will change the players walking anim from a walking to a running aswell as increase its StamMin
and StamMax
values. StamMin and StamMin are sorta like the Humanoid.Health
and Humanoid.MaxHealth
of the stamina. StamMin and StamMax are int-values. and its value changes based on the number of another invalue called Stamina
. StamMax,StamMin and Stamina
all work together to tell the player how much stamina they have left to run(You proabably know how a stamina bar works). This is all displayed on a [bar.](Top one is Stamina)(https://gyazo.com/8c1f7962ed74dfb13ffdf9d77c0a156e) that tells the StamMin over the StamMax.
Problem
So here is my problem. Pretend there is Player1 and Player2 in one server. For some reason Player1 StamMin Max value would be set to whatever Player2's StamMax is. It's confusing but i've done test about 100 times and thats what i could figure out.
Attempts
I haven't figured out a set reason why this is happening meaning that i couldn't establish a good attempt. I've tried attempts but they are more guesses that attempts.
Server Script
--Strength DataStore local DataStoreService = game:GetService("DataStoreService") StrengthD = DataStoreService:GetDataStore("PlayerStrength3") --Armour DataStore local DataStoreService = game:GetService("DataStoreService") ArmourD = DataStoreService:GetDataStore("PlaryerArmour2") --Regen DataStore local DataStoreService = game:GetService("DataStoreService") RegenD = DataStoreService:GetDataStore("PlaryerRegen2") --RegenF local DataStoreService = game:GetService("DataStoreService") RegenFD = DataStoreService:GetDataStore("PlaryerRegen2") --Agility DataStore local DataStoreService = game:GetService("DataStoreService") AgilityD = DataStoreService:GetDataStore("PlaryerAgility2") --Stamina DataStore local DataStoreService = game:GetService("DataStoreService") StaminaD = DataStoreService:GetDataStore("PlaryerStamina2") --StamMin DataStore local DataStoreService = game:GetService("DataStoreService") StamMinD = DataStoreService:GetDataStore("PlaryerStamMin2") --StamMax DataStore local DataStoreService = game:GetService("DataStoreService") StamMaxD = DataStoreService:GetDataStore("PlaryerStamMax2") --Rank DataStore local DataStoreService = game:GetService("DataStoreService") RankD = DataStoreService:GetDataStore("PlayerRanks3") --DiceDR DataStore local DataStoreService = game:GetService("DataStoreService") DiceDRD = DataStoreService:GetDataStore("PlaryerDice2") game.Players.PlayerAdded:Connect(function(Player) local char = Player.Character or Player.CharacterAdded:Wait() local Stats = Instance.new("Folder") Stats.Parent = Player Stats.Name = "Stats" --Strength-- local Strength = Instance.new("IntValue",Stats) Strength.Name = "Strength" --Armour-- local Armour = Instance.new("IntValue",Stats) Armour.Name = "Armour" --Regen-- local Regen = Instance.new("IntValue",Stats) Regen.Name = "Regen" RegenF = Instance.new("IntValue",Player) RegenF.Name = "RegenF" RegenF.Value = Regen.Value/20 --Agility-- local Agility = Instance.new("IntValue",Stats) Agility.Name = "Agility" --Stamina-- local Stamina = Instance.new("IntValue",Stats) Stamina.Name = "Stamina" local StamMin = Instance.new("IntValue",Stamina) StamMin.Name = "StamMin" StamMin.Value = Stamina.Value * 15 + 100 local StamMax = Instance.new("IntValue",Stamina) StamMax.Name = "StamMax" StamMax.Value = Stamina.Value * 15 + 100 --Rank-- local Rank = Instance.new("IntValue",Stats) Rank.Name = "Rank" --DiceDR-- local DiceDR = Instance.new("IntValue",Stats) DiceDR.Name = "DiceD-Rank" --GetAsync's-- Strength.Value = StrengthD:GetAsync(Player.UserId) or 1 Armour.Value = ArmourD:GetAsync(Player.UserId) or 0 Regen.Value = RegenD:GetAsync(Player.UserId) or 1 Agility.Value = AgilityD:GetAsync(Player.UserId) or 1 Stamina.Value = StaminaD:GetAsync(Player.UserId) or 1 Rank.Value = RankD:GetAsync(Player.UserId) or 1 DiceDR.Value = DiceDRD:GetAsync(Player.UserId) or 0 StamMin.Value = StamMinD:GetAsync(Player.UserId) or 100 StamMax.Value = StamMaxD:GetAsync(Player.UserId) RegenF.Value = RegenFD:GetAsync(Player.UserId) --Give Maxes-- Strength.Changed:Connect(function() StrengthChange(Player,Strength) end) function StrengthChange(Player,Strength) if Strength.Value > 200 then Strength.Value = 200 end end Regen.Changed:Connect(function() RegenChange(Player,Regen,RegenF) end) function RegenChange(Player,Regen,RegenF) RegenF.Value = Regen.Value/20 if Regen.Value > 70 then Regen.Value = 70 end end Agility.Changed:Connect(function() AgilityChange(Player,Agility) end) function AgilityChange(Player,Agility) if Agility.Value > 70 then Agility.Value = 70 end end DiceDR.Changed:Connect(function() DiceDRChange(Player,DiceDR) end) function DiceDRChange(Player,DiceDR) if DiceDR.Value <= 0 then DiceDR.Value = 0 end end Stamina.Changed:Connect(function() StaminaChange(Player,Stamina,StamMax) end) function StaminaChange(Player,Stamina,StamMax) StamMax.Value = Stamina.Value * 15 print(StamMax.Value) if Stamina.Value > 250 then Stamina.Value = 250 end end StamMin.Changed:Connect(function() StamMinChange(Player,StamMin,StamMax) end) function StamMinChange(Player,StamMin) if StamMin.Value > StamMax.Value then StamMin.Value = StamMax.Value end if StamMin.Value <= 0 then StamMin.Value = 0 end end Player.PlayerGui.GuiStastictics.HealthBarLocater.Names.Text = Player.Name if Rank.Value == 1 then Player.PlayerGui.GuiStastictics.HealthBarLocater.Rank.Text = "Rank D" end if Rank.Value == 2 then Player.PlayerGui.GuiStastictics.HealthBarLocater.Rank.Text = "Rank C" end if Rank.Value == 3 then Player.PlayerGui.GuiStastictics.HealthBarLocater.Rank.Text = "Rank B" end if Rank.Value == 4 then Player.PlayerGui.GuiStastictics.HealthBarLocater.Rank.Text = "Rank A" end if Rank.Value == 5 then Player.PlayerGui.GuiStastictics.HealthBarLocater.Rank.Text = "Rank S" end if Rank.Value == 1 then Player.Character.Head.PlayerBill.Frame.PlayerRank.Text = "Rank D" end if Rank.Value == 2 then Player.Character.Head.PlayerBill.Frame.PlayerRank.Text = "Rank C" end if Rank.Value == 3 then Player.Character.Head.PlayerBill.Frame.PlayerRank.Text = "Rank B" end if Rank.Value == 4 then Player.Character.Head.PlayerBill.Frame.PlayerRank.Text = "Rank A" end if Rank.Value == 5 then Player.Character.Head.PlayerBill.Frame.PlayerRank.Text = "Rank S" end Player.Character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None end) game.Players.PlayerRemoving:Connect(function(Player) StrengthD:SetAsync(Player.UserId, Player.Stats.Strength.Value) ArmourD:SetAsync(Player.UserId, Player.Stats.Armour.Value) RegenD:SetAsync(Player.UserId, Player.Stats.Regen.Value) AgilityD:SetAsync(Player.UserId, Player.Stats.Agility.Value) StaminaD:SetAsync(Player.UserId, Player.Stats.Stamina.Value) RankD:SetAsync(Player.UserId, Player.Stats.Rank.Value) DiceDRD:SetAsync(Player.UserId, Player.Stats["DiceD-Rank"].Value) StamMinD:SetAsync(Player.UserId, Player.Stats.Stamina.StamMin.Value) StamMaxD:SetAsync(Player.UserId, Player.Stats.Stamina.StamMax.Value) end)
There are more scripts to this but i think this is where all the problems are happpening. If you need the whole thing please do so tell me.
Regards, Bl_ueHistory