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

How to Obtain Functional Gear from a Button in a Click-To-Open GUI?

Greetings, I have quite the issue I'm facing at the moment

As displayed in the title, I am having trouble finding compatible scripts to carry out what I would like to do. My wish is to make a user have the ability to click a brick which will bring up a screen GUI containing a variety of buttons, in which the player may select the gear they wish to get.

For example, what I wish to do specifically is have the character click a brick over a fridge, which will bring up a frame. From there, a vast portion of food will be available. By clicking the corresponding button to the food you wish to have, you will gain the gear in your inventory, but the gear must be functional (such as being able to drink a Bloxy Cola. I have had the issue in the past where the gear is not functional.)

If anyone is able to assist, please do reach out, I have been quite stumped. Thank you for taking the time to read this :)

1 answer

Hello there!

To open your Gui from a part, you could write this: (Including Tweening)

-- Server script
local part = script.Parent
local event = workspace.Open

part.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		event:FireClient(plr)
	end
end)

-- Client script
local frame = script.Parent
local button = frame.Close
local open = frame.Open.Value
local event = workspace.Open

event.OnClientEvent:Connect(function()
	if not open then
		frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Bounce", 0.8, true)
		wait(0.8)
		open = true
	end
end)

button.MouseButton1Click:Connect(function()
	if open then
		frame:TweenPosition(UDim2.new(0.5, 0, 1.5, 0), "Out", "Bounce", 0.8, true)
		wait(0.8)
		open = false
	end
end)

Then, for your gear selector button, you could use the Clone() function. Here is a great source for these kind of things: https://developer.roblox.com/en-us/

Good luck!!!

2 comments

0

Or you could just modify the PlayerGui Instances within the Player Object obtained in the Touched event..?

0

Yeah! I guess you could :D

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