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 » Scripters
Home Search
 

Re: Changing From Hint to GUI

Previous Thread :: Next Thread 
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
05 Feb 2015 06:21 PM
How would I change this hint to GUI? I want the GUI to be only seen when they are on touched with them.



function Touched(hit)
m = Instance.new("Hint")
m.Parent = game.Workspace
m.Text = ("WARNING: Shield Defences Online")
wait(1)
m:Remove()
e = Instance.new("Explosion")
e.Parent = game.Workspace
e.Position = hit.Position
e.BlastPressure = 10
e.BlastRadius = 5
end
script.Parent.Touched:connect ("Touched")
Report Abuse
EliteDerper is not online. EliteDerper
Joined: 05 Feb 2012
Total Posts: 2288
05 Feb 2015 07:02 PM
m.Parent = hit.Parent
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
05 Feb 2015 08:40 PM
If I was weather to change it to a GUI instead of a hint would it be.

script.frame.clone()

Did i do this correct?
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
05 Feb 2015 09:29 PM
Help, I am stuck.
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
05 Feb 2015 09:32 PM
Clone a premade gui into the player's playerGui.

Say you have a gui in ServerStorage named 'TestGui'?
Edit accordingly

local guiName = 'TestGui'
local gui = game.ServerStorage:FindFirstChild(guiName)

script.Parent.Touched:connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then if gui then gui:Clone().Parent = plr.PlayerGui end end
end)
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
05 Feb 2015 09:41 PM
Okay like this?

function Touched(hit)
local guiName = 'TestGui'
local gui = game.ServerStorage:FindFirstChild(guiName)

script.Parent.Touched:connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then if gui then gui:Clone().Parent = plr.PlayerGui
e = Instance.new("Explosion")
e.Parent = game.Workspace
e.Position = hit.Position
e.BlastPressure = 10
e.BlastRadius = 5
end
script.Parent.Touched:connect (Touched)
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
05 Feb 2015 09:54 PM
No, assuming 'TestGui' is valid.. dis.

local guiName = 'TestGui'
local gui = game.ServerStorage:FindFirstChild(guiName)

script.Parent.Touched:connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then if gui then gui:Clone().Parent = plr.PlayerGui
e = Instance.new("Explosion",workspace)
e.Position = hit.Position
e.BlastPressure = 10
e.BlastRadius = 5
end)

Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
06 Feb 2015 06:29 PM
Okay , thank you for helping

What does his line do?
local guiName = 'TestGui'
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
06 Feb 2015 06:35 PM
:/
Report Abuse
bloxx97 is not online. bloxx97
Joined: 08 Jan 2008
Total Posts: 40
06 Feb 2015 08:20 PM
Essentially GUIs work a lot like functions where you need to create them (and for that matter do not need to create them live while the server is running, but can do it personally in studio mode) and then move them into the player's PlayerGui when the Event triggers your function.

For a GUI to make messages, you're actually going to have to create a GUI that mimics personal messages. Gonna have to create the background, make it black and semi-transparent, and then add a Text Box to it, and then have the GUI's text and background disappear after a few seconds or at the click of a GuiButton that looks like X.

GUIs are a pain in the ass. I bet there's a plugin that allows you to drag and drop GUI elements so that you don't have to do all the manual positioning like in the good old days.

http://wiki.roblox.com/index.php?title=API:Class

If you scroll down to GUI, there's a list of a few GUI classes and then a massive list of Events. If you mean you want them to only see the hint-like GUI when they are physically touching the Part/block/brick/button and then NOT see it when they move off of it - you can use the TouchStarted and TouchEnded Events instead of Touch.

And for what it's worth - this is the actual Touched event syntax pulled from the wiki.

function onTouch(obj)
script.Parent.Transparency=0.8
script.Parent.CanCollide=false
wait(2)
script.Parent.Transparency=0
script.Parent.CanCollide=true
end

script.Parent.Touched:connect(onTouch)

--as in no quotes when you call your function with connect at the end.
--However you've taught me something because I had trouble understanding the event handler (hit). I thought this script was cheese until I searched around to find the event handler refers to the Part that is touched. Because really in my mind I would just set the explosion to script.Parent - why would anyone even refer to the same brick in two different ways if the script is already in the Part that it wants to listen to?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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