Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

StaminaGui Frame won't resize. What's the problem?

Asked by 6 years ago

(Note: The game is filtered enabled) (Note: The "stamFolder" isn't being created for some odd reason) (Note: There are no errors in output)

-- THIS IS THE LOCAL SCRIPT

-- Variables

local replicatedStorage = game:GetService("ReplicatedStorage")
local sprintEvent = replicatedStorage:WaitForChild("sprintEvent")
local sprintEnded = replicatedStorage:WaitForChild("sprintEnded")
local userInput = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local humanoid = plr.Character:WaitForChild("Humanoid")
local stamFolder = Instance.new("Folder", plr)
stamFolder.Name = "stamFolder"
local stamina = Instance.new("IntValue", stamFolder)
stamina.Name = "stamina"
stamina.Value = 100
local staminaBar = script.Parent.background.staminabar
local staminaGui = script.Parent
local isSprinting = false
local canSprint = true


-- Scripting
userInput.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        isSprinting = true
        sprintEvent:FireServer()
        while isSprinting and stamina > 0 do
            staminaBar:TweenSize(UDim2.new(stamina * 0.01, 0, 1, 0), "Out", "Sine", .5)
            stamina = stamina - 1
            wait(.2)
        end
        if humanoid.WalkSpeed == 16 then
            isSprinting = false
        end
    end
end)


userInput.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        isSprinting = false
        sprintEnded:FireServer()
        while isSprinting and stamina < 100 do
            stamina = stamina + 1
            staminaBar:TweenSize(UDim2.new(stamina * 0.01, 0, 1, 0), "Out", "Sine", .5)
        end
        if stamina >= 33 then
            canSprint = true
        elseif stamina == 0 then
            canSprint = false
        end
    end
end)


-- THIS IS THE SCRIPT IN SERVERSCRIPTSERVICE

--// Variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local sprintEvent = Instance.new("RemoteEvent", ReplicatedStorage)
sprintEvent.Name = "sprintEvent"
local sprintEnded = Instance.new("RemoteEvent", ReplicatedStorage)
sprintEnded.Name = "sprintEnded"

local function onSprintEventFired(player)
    player.Character:WaitForChild("Humanoid").WalkSpeed = 20
end

sprintEvent.OnServerEvent:Connect(onSprintEventFired)

local function onSprintEndedFired(player)
    player.Character:WaitForChild("Humanoid").WalkSpeed = 16
end

sprintEnded.OnServerEvent:Connect(onSprintEndedFired)




0
as for the stamfolder, i dont think you can create new instances on client side while filtering enabled is on. try to create it on server side deerdharok 91 — 6y

Answer this question