what do u mean what type of value is it? the MaxStamina controls how much Stamina u have for the whole script and i want to change it depending where u are so i made it based off the a number value but it doesnt update
It’s hard to tell what the issue is without more code or a video demonstration. But from what it sounds like, you’re probably managing a server-side property client-side, where it won’t replicate to the server.
-- Variables
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
-- Tweens
local TS = game:GetService("TweenService")
local Tweeninfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local FreezingTween = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local ColdColor = {
BackgroundColor3 = Color3.fromRGB(196, 255, 251)
}
local WarmColor = {
BackgroundColor3 = Color3.fromRGB(255, 101, 96)
}
local Freezing0 = {
ImageTransparency = 0
}
local Freezing1 = {
ImageTransparency = 1
}
local UDied = {
ImageTransparency = 0
}
local UDiedText = {
TextTransparency = 0
}
local ColdTween = TS:Create(script.Parent.StaminaBar.BlueFrame,Tweeninfo,ColdColor)
local WarmTreen = TS:Create(script.Parent.StaminaBar.BlueFrame,Tweeninfo,WarmColor)
local Freezing0 = TS:Create(script.Parent.Freezing,FreezingTween,Freezing0)
local Freezing1 = TS:Create(script.Parent.Freezing,FreezingTween,Freezing1)
local Death = TS:Create(script.Parent.Death,Tweeninfo,UDied)
local DeathText = TS:Create(script.Parent.Death.TextLabel,Tweeninfo,UDiedText)
-- Tweens
-- For the Stamina
local isSprinting = false
local MaxStamina = game:WaitForChild("ReplicatedStorage"):WaitForChild("Blizzard"):WaitForChild("ColdValue").Value
local stamina = MaxStamina
local staminaBar = script.Parent:WaitForChild("StaminaBar")
-- Functions
local function sprint(SType)
local humanoid = char:FindFirstChild("Humanoid")
if SType == "Began" then
isSprinting = true
elseif SType == "Ended" then
isSprinting = false
end
end
-- Stamina: Check if it on moblie
-- For PC
local hotValue = game.Players.LocalPlayer.PlayerGui.Uis.ColdOrHot.HotValue
local function Update()
if hotValue.Value == false then
sprint("Began")
else
sprint("Ended")
end
end
hotValue.Changed:Connect(Update)
-- Updating
game:GetService("RunService").RenderStepped:Connect(function()
local humanoid = char:FindFirstChild("Humanoid")
if stamina == 0 or stamina == 1 then
humanoid.Health = nil
Death:Play()
DeathText:Play()
wait(2)
script.Parent.Death.Visible = false
stamina = 700
end
if isSprinting then
if stamina == 400 then
humanoid.WalkSpeed = humanoid.WalkSpeed - 4
ColdTween:Play()
Freezing0:Play()
end
end
if isSprinting then
stamina = stamina - 1 -- Run
else
stamina = stamina + 1 -- Rest
if stamina == 401 then
WarmTreen:Play()
Freezing1:Play()
humanoid.WalkSpeed = humanoid.WalkSpeed + 4
end
end
stamina = math.clamp(stamina,0,MaxStamina)
staminaBar.BlueFrame.Size = UDim2.new(stamina/MaxStamina,0,1,0)
end)
while wait() do
print(MaxStamina)
end
so what im trying to do is this, blizzards will form randomly around the map and when they do i want the players Stamina to Decrease to a smaller dumber, when its over it increases back to the normal
local hotValue = game.Players.LocalPlayer.PlayerGui.Uis.ColdOrHot.HotValue
local function Update()
if hotValue.Value == false then
sprint("Began")
else
sprint("Ended")
end
end
hotValue.Changed:Connect(Update)
this is getting updated but idk how to do it for this
local MaxStamina = game:WaitForChild("ReplicatedStorage"):WaitForChild("Blizzard"):WaitForChild("ColdValue").Value
i dont know how to use the .Changed but i tried this and it dident work lol
local MaxStamina = game:WaitForChild("ReplicatedStorage"):WaitForChild("Blizzard"):WaitForChild("ColdValue").Value
game:WaitForChild("ReplicatedStorage"):WaitForChild("Blizzard"):WaitForChild("ColdValue").Changed:Connect(MaxStamina)
--not using .Value here
local MaxStamina = game:WaitForChild("ReplicatedStorage"):WaitForChild("Blizzard"):WaitForChild("ColdValue")
--will show the current value
print(MaxStamina.Value)
Did you notice I removed .Value from the MaxStamina variable? Also make sure you are changing it on the server if it’s a server script, else the results wont be valid.