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

How would I script this local SellGUI properly?

Asked by 4 years ago

I am making a Simulator game on Roblox. I want to make it so when your backpack maxes out you get a popup GUI saying that your backpack is full. I have made the GUI and everything I Just need help on the script. This is the script I have:

`local SellGUI = script.Parent.Parent
Swings.Changed:Connect(function()
   script.Parent.Indicator.Text = Swings.Value.."/"..Backpack1.Value
   if Swings.Value >= Backpack1.Value then -- checks if the swing value is more/equal to the backpack value     
    SellGUI.Enabled = true
end
end)`

It all works, but the local SellGUI isn't set up to the right place. I have tried for hours and I can't properly link it for the life of me. The SellGUI is located in the StarterGUI Inside of a GUI named backpack. It is a Frame. The Script is local script located in the same backpack GUI. But, under another Frame which is Main. **The Parenting doesn't work as they are not parented to each other. I have posted a picture with this post. **

The LocalScript is where the Script is located if that helps at all and the script Open has NOTHING to do with this

https://gyazo.com/cfd796e146c990a17b631ba680baf02b

Thanks in advance!

0
what do you mean by "set up" AnasBahauddin1978 715 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

So, from what I understand, when you max out swings, you want to press sell, which then sells them? That is pretty easy, actually, so let's get started!

So, first, create a remote event in workspace. Name the remote event SellEvent, then create a script in workspace, and name it 'SellHandler'. Put the remote event in the script.

Here, I assume you store money in leaderstats, because you haven't given our that information. As well, I also assume that you store swings in leaderstats. If you store them elsewhere, please, correct the mistake!

I also assume that one swing is worth 2 of your currency.

So, now, we need to handle the sales somehow, open the script, and put the following in there:

local event = script.SellEvent

SellEvent.OnServerEvent:Connect(function(plr)
    plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + swings.Value * 2
end)

And now, the grand finale... In a localscript in the sell button, place this script!

local button = script.Parent
local event = workspace.SellHandler.SellEvent

button.Activated:Connect(function()
    event:FireServer()
end)

I haven't tested this, so if there are any mistakes, please, let me know!

Ad

Answer this question