generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: GUI Shop

Previous Thread :: Next Thread 
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 09:28 AM
Hey guys, I have 2 annoying features within the current shop I have and I was wondering if you guys can help me remove them.

1) When I touch the block, the shop pops up but when I touch it again, it overlays. Is there a way to remove that or stop that from happening?

2) I would like to know if there is a way to remove the GUI when you walk a certain distance away from the block.

NOTE: I don't have any scripting knowledge and the player that is helping me with the scripts doesn't know how to do this. If you could please tell me how to do this, then that would be great.
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
30 Aug 2014 09:34 AM
1) Use a if line. It should be something like this:

if PLAYER.PlayerGui:FindFirstChild("NAMEGUI") ~= nil then
elseif PLAYER.PlayerGui:FindFirstChild("NAMEGUI") ~= not nil then
-- do stuff
end
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 09:40 AM
No that didn't work, this was the code I currently had before if that helps. I tried adding your section but it didn't change at all.

local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end;Spawn(wait)
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
user = game.Players:findFirstChild(human.Parent.Name)
script.Parent.ShopGUI:clone().Parent = player.PlayerGui
wait(2)
else
wait(2)
debounce = false
end
end
script.Parent.Touched:connect(onTouch)
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
30 Aug 2014 09:43 AM
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end;Spawn(wait)
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
user = game.Players:findFirstChild(human.Parent.Name)
if user.PlayerGui:FindFirstChild("ShopGUI") ~= nil then
elseif user.PlayerGui:FindFirstChild("ShopGUI") ~= not nil then
script.Parent.ShopGUI:clone().Parent = player.PlayerGui
wait(2)
else
wait(2)
debounce = false
end
end
end
script.Parent.Touched:connect(onTouch)

-- If this doesn't work, please tell me whats wrong and if it gives any errors.
Report Abuse
ARisings is not online. ARisings
Joined: 02 Feb 2014
Total Posts: 90
30 Aug 2014 09:48 AM

function()
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end;Spawn(wait)
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
user = game.Players:findFirstChild(human.Parent.Name)
script.Parent.ShopGUI:clone().Parent = player.PlayerGui
wait(2)
else
wait(2)
debounce = false
New.Instance ("Explosion")
end
end
script.Parent.Touched:connect(onTouch)










Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
30 Aug 2014 09:50 AM
Nice explosion creation :3
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 10:05 AM
No errors or anything and works perfectly, thanks planesoldier, I am guessing I put the if section in the wrong place :P

Would you know how to do the second part where the GUI disapears when you walk a certain distance away from the block? I was told that it has to check the torso or something on the lines of that.

Thanks again for the help :P
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 10:06 AM
Just found out that when I exit the shop, I can't enter the shop again but no error popped up.
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
30 Aug 2014 10:33 AM
I'm sorry, i have no idea how to do the walk away thing. And for the other problem, check if the gui is still in the player's PlayerGui. Because then you didn't make it remove but made it invisible.
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 10:38 AM
When I go towards the shop, the GUI is in the PlayerGui. When I exit the shop, it is removed from the PlayerGui and when I go towards the shop again, it doesn't seem to go back to the PlayerGui.
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 11:03 AM
Bump.
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 11:13 AM
Just found out that there was a script for the exit button :P

I was wondering if this helps or if I need to change anything?

function exit()
wait(0)
script.Parent.Parent.Parent:remove()
end
script.Parent.MouseButton1Down:connect(exit)
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
30 Aug 2014 11:55 AM
You forgot to make the Debounce false again if the human is nil. You did it for the not nil though. This script should fix it if im right...

local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end;Spawn(wait)
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
user = game.Players:findFirstChild(human.Parent.Name)
if user.PlayerGui:FindFirstChild("ShopGUI") ~= nil then
elseif user.PlayerGui:FindFirstChild("ShopGUI") ~= not nil then
script.Parent.ShopGUI:clone().Parent = player.PlayerGui
wait(2)
debounce = false
else
wait(2)
debounce = false
end
end
end
script.Parent.Touched:connect(onTouch)
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 12:06 PM
Still does the same thing where I touch the brick, it opens the GUI and when I touch it again, it no longer overlays which is good.

But when I press exit, I am unable to use the shop again. Whether it has something to do with the exit script, I am unsure but here it is:

function exit()
wait(0)
script.Parent.Parent.Parent:remove()
end
script.Parent.MouseButton1Down:connect(exit)
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
30 Aug 2014 12:32 PM
This probably won't work, but its worth a try. Do this instead.

function exit()
wait()
script.Parent.Parent.Parent:Remove()
end
script.Parent.MouseButton1Down:connect(exit)
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 01:40 PM
Well what would happen is that if you go to the shop, you will get the GUI popping up, you can exit and if you touch the brick again, the shop will reappear.

What I found out is that if you enter the shop twice without clicking exit, you are unable to use the shop again which I think is just odd. Will there be a way to fix this or would I have to just hope players don't enter the shop twice?

Also I was wondering if there was a way to remove the GUI if the user comes in contact of a brick, that way once they exit through the door, the GUI will be removed.
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 02:36 PM
This is a little annoying because I found out that if a user enters the shop twice, no one can use the shop, anyone got an idea on how that can be fixed?
Report Abuse
Bradderz369 is not online. Bradderz369
Joined: 27 Jul 2009
Total Posts: 343
30 Aug 2014 03:53 PM
Bump.

Still can't find out why my GUI won't pop up anymore once I enter the shop twice without hitting the exit button. If you want me to re paste the code, just let me know.
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
31 Aug 2014 05:24 AM
To remove it when they exit the shop, put this script in a brick.

Workspace.Part.Touched:connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") ~= nil then
local Character = game.Players:GetPlayerFromCharacter(Part.Parent)
if Character.PlayerGui:FindFirstChild("NAMEOFGUI") ~= nil then
Character.PlayerGui:FindFirstChild("NAMEOFGUI"):Remove()
end
end
end)
Report Abuse
planesoldier is not online. planesoldier
Joined: 26 Sep 2010
Total Posts: 533
31 Aug 2014 05:25 AM
I'm sorry,
Workspace.Part.Touched:connect(function(Part) should be
script.Parent.Touched:connect(function(Part)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image