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

Not a Valid Member of Frame error?

Everytime I use this script in my Gui in game, I get a error saying 'Sorry, CashUpgrade is not a valid member of Frame' When it's inside the Frame and the Property of the 'CashUpgrade' states 'Frame'

Anyone know about this error? I've had this error multiple times and don't understant why.

This is a LocalScript

It say's the error line is Line 09

local bloxyColaId = 1378997337 -- Change this to your gamepass ID
local player = game.Players.LocalPlayer
local frame = script.Parent

frame.ImageButton.MouseButton1Click:connect(function()
game:GetService("MarketplaceService"):PromptPurchase(player, bloxyColaId) 
end)

frame.CashUpgrade.MouseButton1Click:connect(function()
if player.leaderstats.Money.Value >= 25000 and player.leaderstats.Upgrade.CashUpgrade.Value == 0 then
player.leaderstats.Money.Value = player.leaderstats.Money.Value - 25000
player.leaderstats.Upgrade.CashUpgrade.Value = 1
frame.CashUpgrade.Cash.Text = 'Level 1 Bought!'
wait(2)
frame.CashUpgrade.Cash.Text = 'Upgrade Cash Amount'
if player.leaderstats.Money.Value >= 95000 and player.leaderstats.Upgrade.CashUpgrade.Value == 1 then
player.leaderstats.Money.Value = player.leaderstats.Money.Value - 95000
player.leaderstats.Upgrade.CashUpgrade.Value = 2
frame.CashUpgrade.Cash.Text = 'Level 2 Bought!'
wait(2)
frame.CashUpgrade.Cash.Text = 'Upgrade Cash Amount'
if player.leaderstats.Money.Value >= 250000 and player.leaderstats.Upgrade.CashUpgrade.Value == 2 then
player.leaderstats.Money.Value = player.leaderstats.Money.Value - 250000
player.leaderstats.Upgrade.CashUpgrade.Value = 3
frame.CashUpgrade.Cash.Text = 'Maxed Cash Bought!'
wait(2)
frame.CashUpgrade.Cash.Text = 'Upgrade Cash Amount'
end
end
end
end)

1 answer

MouseButton1Click can’t be used in frames as it isn’t a button. There’s a reason why there’s buttons and not frames only. :P

Simply replace the CashUpgrade frame with a TextButton or ImageButton and it should work.

2 comments

0

The CashUpgrade isn't a Frame.. It's a ImageButton

0

It Apparently works when I add the 'WaitForChild' saying the script loads too fast for the game to comprehend that there's a CashUpgrade button inside the Frame.

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