Fearrin
|
  |
| Joined: 28 Feb 2015 |
| Total Posts: 184 |
|
|
| 17 Dec 2016 11:05 PM |
local Button = script.Parent local Frame = game.ServerStorage.CandyGui.TextBox
function onClick() game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) Frame:Clone().Parent = player.StarterGui end) end) end
Button.MouseButton1Click:connect(onClick) |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2016 11:07 PM |
"end)"
character not valid function
try output |
|
|
| Report Abuse |
|
|
Fearrin
|
  |
| Joined: 28 Feb 2015 |
| Total Posts: 184 |
|
| |
|
|
| 17 Dec 2016 11:10 PM |
Try removing the ) on the end.
|
|
|
| Report Abuse |
|
|
PIans
|
  |
| Joined: 23 Aug 2013 |
| Total Posts: 11 |
|
|
| 17 Dec 2016 11:11 PM |
When you call the function, you have two events that start:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character)
Try removing these two events and see if you get the result that you want. |
|
|
| Report Abuse |
|
|
Fearrin
|
  |
| Joined: 28 Feb 2015 |
| Total Posts: 184 |
|
|
| 17 Dec 2016 11:14 PM |
I removed game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) and then this happened in the output 22:13:06.770 - Workspace.Part.SurfaceGui.Frame.TextButton.Script:6: attempt to index global 'player' (a nil value) |
|
|
| Report Abuse |
|
|
PIans
|
  |
| Joined: 23 Aug 2013 |
| Total Posts: 11 |
|
|
| 17 Dec 2016 11:15 PM |
"player" is undefined, try defining it as LocalPlayer:
local player = game.Players.LocalPlayer |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2016 11:16 PM |
"nil value"
if you removed that, the lines in the script wouldn't know what it will connect to. Making it a nil.
Maybe put CandyGui in startergui.
change character to player. |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2016 11:20 PM |
local Button = script.Parent local Frame = game.ServerStorage.CandyGui.TextBox
function onClick() game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) Frame:Clone().Parent = player.StarterGui end) end) end
Button.MouseButton1Click:connect(onClick)
See on the 5th line u have a function, having another function inside usually and sometimes rarely works. Try having this... VVVVVVVVVV
local Button = script.Parent local Frame = game.ServerStorage.CandyGui.TextBox
function onClick() game.Players.PlayerAdded:connect(function(player) end) player.CharacterAdded:connect(function(character) Frame:Clone().Parent = player.StarterGui end) end
Button.MouseButton1Click:connect(onClick)
I closed and separated the functions, u need to have one function and one event separate from any other functions and events. U put one function inside the other, it can't perform like that. This way when your player is added it will respond separately then when your character will spawn. |
|
|
| Report Abuse |
|
|
Fearrin
|
  |
| Joined: 28 Feb 2015 |
| Total Posts: 184 |
|
|
| 17 Dec 2016 11:22 PM |
I add local player = game.Players.LocalPlayer but the output says 22:20:15.728 - Workspace.Part.SurfaceGui.Frame.TextButton.Script:7: attempt to index upvalue 'player' (a nil value) and I can't put the gui in startergui since I only want it to appear when the script parent is clicked |
|
|
| Report Abuse |
|
|
Fearrin
|
  |
| Joined: 28 Feb 2015 |
| Total Posts: 184 |
|
|
| 17 Dec 2016 11:24 PM |
I tried your script and didnt work and output states 22:23:45.553 - Workspace.Part.SurfaceGui.Frame.TextButton.Script:8: attempt to index upvalue 'player' (a nil value)
|
|
|
| Report Abuse |
|
|
|
| 17 Dec 2016 11:25 PM |
You can sitll make it work when the gui is in screen gui.
Place gui in screengui
Make scripts into localscripts, inside gui
|
|
|
| Report Abuse |
|
|
|
| 17 Dec 2016 11:26 PM |
What exactly do you want the script to do?
|
|
|
| Report Abuse |
|
|
Fearrin
|
  |
| Joined: 28 Feb 2015 |
| Total Posts: 184 |
|
|
| 17 Dec 2016 11:30 PM |
| I want the script to clone and move a gui that is serverstorage to startergui by clicking on surface gui textbutton. |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2016 11:39 PM |
Frame:Clone().Parent = player.StarterGui
Your cloning startergui inside player. Try:
Frame:Clone().Parent = ServerStorage.CandyGui
then add in your other lines to clone it into the startergui |
|
|
| Report Abuse |
|
|
Fearrin
|
  |
| Joined: 28 Feb 2015 |
| Total Posts: 184 |
|
|
| 17 Dec 2016 11:50 PM |
| That won't work because I need the candygui to go into the startergui |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 17 Dec 2016 11:59 PM |
@OP
YOU CAN'T ACCESS SERVERSTORAGE FROM LOCAL SCRIPT
PLACE THE GUI IN REPLICATEDSTORAGE
|
|
|
| Report Abuse |
|
|