local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
--//Models\\--
local deadliftBar = game.Workspace.deadliftBar
local squatBar = game.Workspace.squatBar
local squatRack = game.Workspace:WaitForChild("squatRack")
local squatRackOccupied = squatRack:WaitForChild("squatRackOccupied")
local deadliftBool = squatRack:WaitForChild("deadliftBool")
local squatBool = squatRack:WaitForChild("squatBool")
--//Services\\--
local CAS = game:GetService("ContextActionService")
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
--//Gui\\--
local playerGui = plr:WaitForChild("PlayerGui")
local squatRackGui = playerGui:WaitForChild("squatRackGui")
local DeadliftGui = squatRackGui:WaitForChild("Deadlift")
local SquatGui = squatRackGui:WaitForChild("Squat")
local squatRackFGui = playerGui.squatRackGuiFolder:WaitForChild("squatRackFGui")
local deadliftOffGui = squatRackGui:WaitForChild("deadliftOffGui")
local squatOffGui = squatRackGui:WaitForChild("squatOffGui")
local weightSelection = playerGui:WaitForChild("squatRackGui").deadliftWeightChange
--//Deadlift remotes\\--
local getOnDeadlift = RS.squatRackRemotes.deadliftRemote.getOnDeadlift
local deadlift = RS.squatRackRemotes.deadliftRemote.DeadliftEvent
local getOffDeadlift = RS.squatRackRemotes.deadliftRemote.getOffDeadlift
--//Squat remotes\\--
local squatting = RS.squatRackRemotes.squatRemote.SquatEvent
local getOnSquat = RS.squatRackRemotes.squatRemote.getOnSquat
local getOffSquat = RS.squatRackRemotes.squatRemote.getOffSquat
--//Values\\--
local debounce = false
local Owner = plr:WaitForChild("Owner").Value
local deadliftdebounce = false
local deadliftMinimum = 10
local squatdebounce = false
local squatMinimum = 10
local chosenWeight = false
local function deadliftUp(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
if plr.leaderstats.Energy.Value > 0 and plr.leaderstats.Energy.Value >= deadliftMinimum then
if not deadliftdebounce then
if chosenWeight == true then
deadlift:FireServer(value)
deadliftTrack2:Play()
else
print("Choose a weight.")
end
deadliftdebounce = true
wait(2.5)
deadliftdebounce = false
end
end
end
end
deadliftOffGui.MouseButton1Click:Connect(function()
if deadliftdebounce == false then
chosenWeight = false
weightSelection.Visible = false
deadliftOffGui.Visible = false
plr.Owner.Value = "None"
CAS:UnbindAction("deadlift")
getOffDeadlift:FireServer()
deadliftTrack:Stop()
deadliftTrack2:Stop()
end
end)
So for some reason it keeps ignoring the if deadliftdebounce == false
part when I click on the TextButton and automatically does everything inside of the function. How can I get it to check the conditional statement before doing the rest?
#EDIT: I included all of the missing variables.