Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Incomplete statement: expected assignment or a function call Error?

I am running into a problem on my sprinting script. Or the stamina part of it. I keep getting this error: "19:43:24.258 - Players.DAKNCAMGAMING.PlayerScripts.SprintHandler:16: Incomplete statement: expected assignment or a function call"

Here is my script:

local uis = game:GetService('UserInputService')
local players = game:GetService('Players')
local player = players.LocalPlayer
local runStatus = false

local walkSpeedMultiplyer = 2
local originalWalkSpeed = 16
local currentStamina = 500
local maximumStamina = 500
local runningStaminaCost = 5

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and player.Character.Humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics and currentStamina >= 0 then
		runStatus = true
		player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed * walkSpeedMultiplyer
		currentStamina - runningStaminaCost until currentStamina == 0
	end
end)

uis.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		player.Character.Humanoid.WalkSpeed = originalWalkSpeed
	end
end)

1 answer

✓ Accepted answer

I assume you are trying to decrement currentStamina? The until keyword is only used on a repeat until loop. Replace line 16 with the following:

currentStamina = math.clamp(currentStamina - runningStaminaCost, 0, maximumStamina)

math.clamp() is used here to make sure currentStamina is always a value between 0 and maximumStamina

This discussion is preserved as it was. New answers, comments, and votes are closed.