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

Not a Valid Member of Frame error?

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
1
Answered by 6 years ago

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.

0
The CashUpgrade isn't a Frame.. It's a ImageButton Resplendid 3 — 6y
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. Resplendid 3 — 6y
Ad

Answer this question