|
| 07 May 2017 07:58 PM |
Like, I want a brick when on touched it can show up text from the startergui.
Here is an example if you don't know what I mean.
function onTouched(hit) game.Workspace.OldDesk:Play() game.StarterGui.ScreenGui.Frame.OldDeskScript.Disabled = false script.Parent:Destroy() end
script.Parent.Touched:connect(onTouched)
But it doesn't come up every single time I test it, may anybody help me with this? It would be greatly appreciated.
t |
|
|
| Report Abuse |
|
|
|
| 07 May 2017 09:44 PM |
GUIs are local. You can do the 'Get Player From Character' function to get the player. You need a local script to change anything in the GUI.
Also, Starter Gui won't affect the player directly. They need to rest to see the effects. I hope that's what you want.
#code error('Signature not found!') |
|
|
| Report Abuse |
|
|
|
| 07 May 2017 10:05 PM |
If you want it to affect a single player, you need to access the PlayerGui, located in the player.
|
|
|
| Report Abuse |
|
|
|
| 08 May 2017 01:53 AM |
Under your function which is function onTouched make a new statement called player like so. local Player = hit.Parent.Name This is done to get the name of the player who hit the brick via their character. As you can't do local player in a normal script.
Replace game.startergui with game.Players.Player.PlayerGui as the startergui is a place to store gui's that will be passed down/ replicate to the player when the game starts or they respawn, not during gameplay. |
|
|
| Report Abuse |
|
|
|
| 08 May 2017 01:58 AM |
| Plus add a wait before you destroy the script. You don't give it time to actually perform the task you want it to do before you destroy it. 0.3 seconds would be sufficient. |
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 08 May 2017 05:37 AM |
server script: local Remote=Instance.new("RemoteEvent") Remote.Name="Remote" Remote.Parent=game:GetService("ReplicatedStorage")
script.Parent.Touched:Connect(function(Hit) if game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent) then local Player=Players:GetPlayerFromCharacter(Hit.Parent) Remote:FireClient(Player, "ShowGui") end)
client script: Remote.OnClientEvent:Connect(function(...) local Tuple={...} if Tuple[1]=="ShowGui" then --// gui stuff end end) |
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 08 May 2017 05:38 AM |
oops
client script: local Remote=game:GetService("ReplicatedStorage"):WaitForChild("Remote")
Remote.OnClientEvent:Connect(function(...) local Tuple={...} if Tuple[1]=="ShowGui" then --// gui stuff end end) |
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
| |
|
Roardorak
|
  |
| Joined: 13 Jul 2014 |
| Total Posts: 184 |
|
|
| 08 May 2017 05:55 AM |
oh come on i was about to tell him to use a remote event for the server to tell the client what to do.
Ready the rifles, boys! |
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 08 May 2017 07:11 AM |
>replies 20 minutes after what i said
u was about to tell him? ok. |
|
|
| Report Abuse |
|
|
Roardorak
|
  |
| Joined: 13 Jul 2014 |
| Total Posts: 184 |
|
|
| 08 May 2017 03:19 PM |
| no i remembered the idea and came back to the post to tell him |
|
|
| Report Abuse |
|
|
|
| 08 May 2017 07:41 PM |
@Naxxan
client script: local Remote=game:GetService("ReplicatedStorage"):WaitForChild("Remote")
Remote.OnClientEvent:Connect(function(...) local Tuple={...} if Tuple[1]=="ShowGui" then --// gui stuff end end)
What do you mean "--// gui stuff?" |
|
|
| Report Abuse |
|
|
|
| 08 May 2017 08:33 PM |
| To be honest, I really want the code of it, not hints, I'm really stressed out at this type of script. |
|
|
| Report Abuse |
|
|
| |
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 09 May 2017 11:00 PM |
if Tuple[1]=="ShowGui" then DatCoolGui.Visible=true end |
|
|
| Report Abuse |
|
|
Naxxanar
|
  |
| Joined: 13 Jun 2012 |
| Total Posts: 709 |
|
|
| 09 May 2017 11:00 PM |
if ur trying to make a frame visible, then do if Tuple[1]=="ShowGui" then DatCoolGuiFrame.Visible=true end
if its a gui then do if Tuple[1]=="ShowGui" then DatCoolGui.Enabled=true end |
|
|
| Report Abuse |
|
|