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

Part That When Clicked Brings Up A GUI?

Asked by 8 years ago

So I'm just wondering how I would create a tool, lets say a Pizza and when you click on the Pizza it brings up a GUI, this GUI will have a selection of different flavours, lets say Peperoni, Meat Lovers and the Works.

My ONLY problem is, I'm not sure how I'd do that, I want it so that when you click the selection that you want, the Pizza will go into your inventory.

Now I do know that I'm going to add the Tools into the lighting, because I'm pretty sure in order for this script to work the tools will have to go under the lighting?

Also, once the player has clicked the selection of the Pizza He/She wants the GUI will be destroyed, I'm not sure if I'm suppose to use Destroy() or..? And with the GUI, would that go under StarterGUI or lighting?

-iiKeegs

0
And I don't mean when the player hits the Tool, I mean when the player Clicks the Tool. keegfire2000 0 — 8y
0
I'm still not certain on if I'm doing it right. I want it so that when the player clicks the item, a GUI will pop up on his/her screen giving an option of choices, these choices will be tools that go into the players backpack so him/her can use them. I'm not sure if this is the proper script you gave me but I ran across the problems. keegfire2000 0 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Are you asking when the player clicks WITH the tool or clicks the tool directly? In either case, this will not be to much of a problem. But, just a heads up, scripts will not be able to run if they are in the lighting or a descendant of lighting in any way. If you are using lighting to store items then don't. Use ReplicatedStorage now instead.

Put this in a local script inside the tool you want to use:

Tool=script.Parent
player=game.Players.LocalPlayer

function onEquippedLocal(mouse)
mouse.MouseButton1Down:connect(function()
player.PlayerGui["ScreenGui you want"]["Item you want (usually a frame)"].Visible=true
end)
end
Tool.Equipped:connect(onEquippedLocal)

This will make a specific GUI appear when the player clicks with a tool.

If you want the tool to be clicked directly like if the player is clicking on a brick, you can use this:

player=game.Players.LocalPlayer
mouse=player:GetMouse()

mouse.MouseButton1Down:connect(function()
if mouse.Target then
if mouse.Target.Name=="Name of the part you chose" then
player.PlayerGui["ScreenGui you want"]["Item you want (usually a frame)"].Visible=true
end
end
end)

Put this inside the player or the starterpack or whatever. Just make sure it is in a local script.

0
Thank you! You're awesome! keegfire2000 0 — 8y
0
Np, any time. BobserLuck 367 — 8y
0
I'm still not certain on if I'm doing it right. I want it so that when the player clicks the item, a GUI will pop up on his/her screen giving an option of choices, these choices will be tools that go into the players backpack so him/her can use them. I'm not sure if this is the proper script you gave me but I ran across the problems. I put both the ScreenGUI and Frame into the StaterGUI so I could keegfire2000 0 — 8y
Ad

Answer this question