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: What is wrong with this script?

Previous Thread :: Next Thread 
Fearrin is not online. 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
xInitiated_Inspire is not online. xInitiated_Inspire
Joined: 17 Jul 2014
Total Posts: 1276
17 Dec 2016 11:07 PM
"end)"

character not valid function

try output
Report Abuse
Fearrin is not online. Fearrin
Joined: 28 Feb 2015
Total Posts: 184
17 Dec 2016 11:08 PM
output has no errors
Report Abuse
xInitiated_Inspire is not online. xInitiated_Inspire
Joined: 17 Jul 2014
Total Posts: 1276
17 Dec 2016 11:10 PM
Try removing the ) on the end.
Report Abuse
PIans is not online. 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 is not online. 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 is not online. 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
xInitiated_Inspire is not online. xInitiated_Inspire
Joined: 17 Jul 2014
Total Posts: 1276
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
Scripthonx is not online. Scripthonx
Joined: 23 Dec 2015
Total Posts: 20
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 is not online. 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 is not online. 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
xInitiated_Inspire is not online. xInitiated_Inspire
Joined: 17 Jul 2014
Total Posts: 1276
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
xInitiated_Inspire is not online. xInitiated_Inspire
Joined: 17 Jul 2014
Total Posts: 1276
17 Dec 2016 11:26 PM
What exactly do you want the script to do?

Report Abuse
Fearrin is not online. 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
xInitiated_Inspire is not online. xInitiated_Inspire
Joined: 17 Jul 2014
Total Posts: 1276
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 is not online. 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 is not online. 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
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