so say for example you step on a part. You get a GUI that shows up on your screen. But when i tried to do it multiple showed up.
1 | script.Parent.Touched:Connect( function (player) |
2 | local player = game.Players:GetPlayerFromCharacter(player.Parent) |
3 | local shop = game.ServerStorage.ScreenGui:Clone() |
4 | shop.Parent = player:WaitForChild( "PlayerGui" ) |
5 | -- below here i got no idea what to do |
6 | end ) |
ScreenGui
exists in the PlayerGui
, with the Instance:FindFirstChild()
method. If the ScreenGui
was found, we will not do anything. If not, we will clone it so they have it.01 | script.Parent.Touched:Connect( function (part) |
02 | local player = game.Players:GetPlayerFromCharacter(part.Parent) |
03 |
04 | if player then -- we should make sure it's player first |
05 |
06 | if player.PlayerGui:FindFirstChild( "ScreenGui" ) then return end |
07 | -- if a ScreenGui was found, do not do anything, just return out the function |
08 |
09 | local shop = game.ServerStorage.ScreenGui:Clone() |
10 | shop.Parent = player.PlayerGui |
11 | end |
12 | end ) |
Make it so when you touch a part all the rest of the gui's transparency will be 1 except the one you want to show and use the "OnTouchEnded" function to make the guis reappear after the part is not being touched