florodude
|
  |
| Joined: 20 Jan 2009 |
| Total Posts: 240 |
|
|
| 06 Apr 2015 04:27 PM |
| Hey guys, so I have a touch script, which is not a localscript. When I touch it, I want a GUI to appear for just that player, so I'd need to use a local script, I believe. How would I accomplish this? |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 06 Apr 2015 04:29 PM |
Try this,
function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then -- if a humanoid exists, then local p = game.Players:FindFirstChild(part.Parent.Name) if p ~=nil then p.PlayerGui.GuiName.FrameName: -- execute code end end end
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:31 PM |
RemoteEvents :D
assuming that there is a RemoteEvent in replicatedstorage called RE
in a script inside the part
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) game.ReplicatedStorage.RE:FireClient(player, false) end end)
in a localscript inside of you
player = game.Players.LocalPlayer
game.ReplicatedStorage.RE.OnClientEvent:connect(function(bool) player.PlayerGui.YOURGUINAMEHERE.YOURFRAMENAMEHERE.Visible = bool end |
|
|
| Report Abuse |
|
|
florodude
|
  |
| Joined: 20 Jan 2009 |
| Total Posts: 240 |
|
|
| 06 Apr 2015 04:34 PM |
| The first response had an "expected identifier, got 'end'" error, as for the second one, can you explain what the replicated storage does and how I would use it in this situation? |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:41 PM |
ServerStorage is a place for server access only. LocalScripts cannot find anything inside of it. ServerScriptService is the same thing just for scripts.
ReplicatedStorage is a place for server AND client. On Roblox, stuff is replicated from the server to the client. Examples of this stuff is the stuff inside workspace and ReplicatedStorage.
RemoteEvents are a necessity for FilteringEnabled games. FE makes your game more secure and I really recommend making your games while they are FE compatible.
http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial
RemoteEvents are for interacting across the client and server.
@Klink
You shouldn't be using a script for editing a player's gui. |
|
|
| Report Abuse |
|
|
florodude
|
  |
| Joined: 20 Jan 2009 |
| Total Posts: 240 |
|
|
| 06 Apr 2015 04:50 PM |
I'm still having nothing happen. Here is what I did.
Set an empty Remote event inside the replicatedStorage called "RE"
Put this script inside the part:
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) game.ReplicatedStorage.RE:FireClient(player, false) end end)
Put this Localscript inside StarterPack:
player = game.Players.LocalPlayer
game.ReplicatedStorage.RE.OnClientEvent:connect(function(bool) game.StarterGui.ScreenGui.Cost1500.Visible = true; end)
Nothing happens. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 04:54 PM |
NONONONO! In the localscript
It's not game.StarterGui
It's player.PlayerGui |
|
|
| Report Abuse |
|
|
florodude
|
  |
| Joined: 20 Jan 2009 |
| Total Posts: 240 |
|
|
| 06 Apr 2015 05:01 PM |
| Awesome! Works great. One last thing. How do I get it so when I stop touching said part, it will set the visible to false again? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 06 Apr 2015 05:03 PM |
Just use this. It's easier than remote events.
function onTouch(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid ~= nil then local p = game.Players:FindFirstChild(hit.Parent.Name) if p ~= nil then p.PlayerGui.ScreenGui.Frame.Visible = true end end end
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 06 Apr 2015 05:04 PM |
| You really shouldn't use a script for changing stuff in the player. |
|
|
| Report Abuse |
|
|
florodude
|
  |
| Joined: 20 Jan 2009 |
| Total Posts: 240 |
|
|
| 06 Apr 2015 05:35 PM |
| So can somebody please answer the question about stepping off? using either method. |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 06 Apr 2015 05:44 PM |
Like there is a Touched event, there is also a TouchEnded event.
connect a new function with the TouchEnded event |
|
|
| Report Abuse |
|
|