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: Run Localscript from Script

Previous Thread :: Next Thread 
florodude is online. 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 is not online. 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 is not online. 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 is online. 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 is not online. 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 is online. 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 is not online. 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 is online. 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 is not online. 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 is not online. 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 is online. 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 is not online. 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
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