Since only local scripts can be put on server scripts?
Server script(Stamina Regen):
local plr = script.Parent.Parent plr.MaxStamina.Value = (plr.Stats.Vitality.Value*4)+100 local MaxStam = plr.MaxStamina.Value db = false function regenStamina() if not db then db = true while plr.Stamina.Value<MaxStam do plr.Stamina.Value = plr.Stamina.Value + (MaxStam/10) if plr.Stamina.Value>MaxStam then plr.Stamina.Value = MaxStam end wait(1) end if plr.Stamina.Value < 0 then plr.Stamina.Value = 0 end db = false end end function addStamina () MaxStam = (plr.Stats.Vitality.Value*4)+100 plr.MaxStamina.Value = MaxStam regenStamina() end function giveStamina() addStamina() plr.Stamina.Value = MaxStam end plr.CharacterAdded:Connect(giveStamina) plr.Stats.Vitality.Changed:Connect(addStamina) plr.Stamina.Changed:Connect(regenStamina)
Use PlayerAdded
game.Players.PlayerAdded:Connect(function(plr) wait() plr.MaxStamina.Value = (plr.Stats.Vitality.Value*4) + 100 local MaxStam = plr.MaxStamina.Value local db = false —Rest of script end)
This will work for each individual player, you may have to add a wait(1) or WaitForChild() since the folders and values may not have been added yet.
Script, or ServerScripts, are supposed to handle game mechanics, (for example, in a disasters game, they would handle the disasters). Scripts should always be put into ServerScriptService or the Workspace. On the other hand, LocalScripts are supposed to handle thing with the player, for example health regeneration (or stamina). These scripts are only supposed to go into anything that has Starter in its name (ex. StarterPlayerScripts, StarterGui, StarterPack), with a few exceptions. So your script, which deals with player stamina, should be a LocalScript placed inside of StarterPlayerScripts. also you shoud have something like this:
local plr = game.Players.LocalPlayer