Help with button and frame

Hello, so I have a script that I want to open a frame only if you have 1 or more lives. If you dont, it will prompt an error message. What is wrong with my script? It only prompts the error message even though I have 500 lives.

local playButton = script.Parent.Start
local players = game:GetService("Players")
local localPlayer = players.LocalPlayer
local lives = localPlayer.playerstats.Lives.Value
local playFrame = game:GetService("StarterGui").Frames:WaitForChild("PlayFrame")
local frameTrigger = require(game:GetService("StarterGui"):WaitForChild("FrameTrigger"))


playButton.MouseButton1Click:Connect(function()
	if lives >= 1 then
		frameTrigger.OpenFrame("PlayFrame")
	else
		script.Parent.Parent.Error.Visible = true
		task.wait(5)
		script.Parent.Parent.Error.Visible = false
	end
end)

try this script

local playButton = script.Parent.Start
local players = game:GetService("Players")
local localPlayer = players.LocalPlayer
local lives = localPlayer.playerstats.Lives
local playFrame = game:GetService("StarterGui").Frames:WaitForChild("PlayFrame")
local frameTrigger = require(game:GetService("StarterGui"):WaitForChild("FrameTrigger"))


playButton.MouseButton1Click:Connect(function()
	if lives.Value >= 1 then
		frameTrigger.OpenFrame("PlayFrame")
	else
		script.Parent.Parent.Error.Visible = true
		task.wait(5)
		script.Parent.Parent.Error.Visible = false
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.