So i need to do so peoples can buy stages on my simulator game but i cant figure out how to do a touched event that will open a frame that will say Buy stage ? yes or no ive been stuck on it for 2 days :/
I've found a working solution. So my method is to clone the GUI and put it in a player's PlayerGui. This script is very basic (Note: To have multiple frames show up, make sure they are in the ScreenGui you wish to clone.)
local gui = game:GetService("ReplicatedStorage"):WaitForChild("ShopGui") script.Parent.Touched:Connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then local clonedgui = gui:Clone() local player = game.Players:GetPlayerFromCharacter(hit.Parent) clonedgui.Parent = player.PlayerGui end end)
I will entertain your question because you are new.
For future reference, you must first try to make the script yourself, then if it doesn't work, come to us for help.
You will have to fill in a couple of things as you didn't give me a script to fix:
local PartThatIsTouched = workspace.PartNameHere local PlayerGui = game.Players.PlayerGui repeat wait() until PlayerGui:FindFirstChildOfClass'ScreenGui' local ScreenGui = PlayerGui:FindFirstChildOfClass'ScreenGui' local GuiToPopUp = ScreenGui:WaitForChild( "Your gui name here" -- put your gui name here between the quotes ) PartThatIsTouched.Touched:connect(function() GuiToPopUp.Visible = true end) GuiToPopUp:WaitForChild( "Your first button name here" ).MouseButton1Click:connect(function() -- your code here end) GuiToPopUp:WaitForChild( "Your second button name here" ).MouseButton1Click:connect(function() -- your code here end)
As seen on the Wiki, onTouch can be called via both LocalScripts and normal Scripts.
In order to do what you're asking you should place a LocalScript inside of
StarterPlayer > StarterPlayerScripts
Inside of this localscript you should define your part that's located inside of the workspace. Please replace PARTNAME with your parts name.
local Part = game:GetService("Workspace"):WaitForChild("PARTNAME") local Players = game:GetService("Players") local LocalPlayer = Players.LocalPlayer local gui = game:GetService("ReplicatedStorage"):WaitForChild("ShopGui") Part.Touched:connect(function(partTouched) if Players:GetPlayerFromCharacter(partTouched.Parent) and partTouched.Parent.Name == LocalPlayer.Name then if gui.Frame.Visible == false then gui.Frame.Visible = true end end end)
Please mark this as your solution if it helped.
Closed as Not Constructive by Ziffixture, CaptainD_veloper, and theking48989987
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?