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 » Game Design
Home Search
 

Re: Why isn't this script working?

Previous Thread :: Next Thread 
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 10:38 AM
Why isn't this script working?

local player = game.Players.LocalPlayer
local clone = game.ReplicatedStorage.Pyro:Clone()

script.Parent.ClickDetector.MouseClick:connect(function()
clone.Parent = player.Backpack
end)

The script is in a localscript, in a part with a ClickDetector
The name of the tool is correct before you ask.

Posted this before, but it was in the wrong section so I'm posting it here.
Plus, I wasn't getting much help in the other section.
Some guys in the other section tried helping, but none of their solutions worked.
Report Abuse
CorruptScript is online. CorruptScript
Joined: 16 Nov 2011
Total Posts: 3873
11 Dec 2016 10:42 AM
Define the local player inside the function or else the script has no idea who you are talking about.


-The Time Traveling Knight of OT
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 10:43 AM
Thanks, will try this now. I'm new to scripting so that's why I didn't know.
Report Abuse
CorruptScript is online. CorruptScript
Joined: 16 Nov 2011
Total Posts: 3873
11 Dec 2016 10:43 AM

local clone = game.ReplicatedStorage.Pyro:Clone()

script.Parent.ClickDetector.MouseClick:connect(function()
local player = game.Players.LocalPlayer
clone.Parent = player.Backpack
end)


-The Time Traveling Knight of OT
Report Abuse
CorruptScript is online. CorruptScript
Joined: 16 Nov 2011
Total Posts: 3873
11 Dec 2016 10:44 AM
Np.


-The Time Traveling Knight of OT
Report Abuse
CorruptScript is online. CorruptScript
Joined: 16 Nov 2011
Total Posts: 3873
11 Dec 2016 10:45 AM
You may also want to define 'clone' inside the function as well, otherwise it will only work once.


-The Time Traveling Knight of OT
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 10:52 AM
Alright will do this to, thanks.
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 10:57 AM
Hmm, just did this and it still doesn't work :/
Report Abuse
CorruptScript is online. CorruptScript
Joined: 16 Nov 2011
Total Posts: 3873
11 Dec 2016 11:00 AM
The script should look like this.

script.Parent.ClickDetector.MouseClick:connect(function()
local clone = game.ReplicatedStorage.Pyro:Clone()
local player = game.Players.LocalPlayer
clone.Parent = player.Backpack
end)


-The Time Traveling Knight of OT
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 11:02 AM
I must've made a spelling mistake somewhere, lemme just check it
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 11:09 AM
I double checked to make sure, and it's exactly like that but doesn't work.
Report Abuse
Spoookd is not online. Spoookd
Joined: 23 Jan 2016
Total Posts: 269
11 Dec 2016 11:09 AM
Defining the local variables outside the script is the same thing as putting them in (unless you were using them in other functions while its in its own).

Try 'MouseButton1Click' instead of 'MouseClick'

Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 11:12 AM
I thought 'MouseButton1Click' was for Gui buttons? This is just a part with a ClickDetector, not a Gui.

I could be wrong, trying it anyway.
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 11:15 AM
Just as I imagined, didn't work.
Report Abuse
Spoookd is not online. Spoookd
Joined: 23 Jan 2016
Total Posts: 269
11 Dec 2016 11:17 AM
Oh yea sorry my bad I never use clickdetectors. Since it is in a local script take it and put it in a script.

If that doesnt work, try putting the script in serverscriptservice.
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 11:21 AM
But then it still wouldn't work because you can only use game.Players.LocalPlayer in LocalScripts. How do I define the player in a normal script?

Report Abuse
Spoookd is not online. Spoookd
Joined: 23 Jan 2016
Total Posts: 269
11 Dec 2016 11:29 AM
Omg I am bad xD Try setting the clone's parent to lighting or something before setting it in the function.

local player = game.Players.LocalPlayer
local clone = game.ReplicatedStorage.Pyro:Clone()
clone.Parent = game.Lighting

script.Parent.ClickDetector.MouseClick:connect(function()
clone.Parent = player.Backpack
end)
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 11:36 AM
Still doesn't work :/
Report Abuse
Spoookd is not online. Spoookd
Joined: 23 Jan 2016
Total Posts: 269
11 Dec 2016 11:40 AM
Go to a website called Scripting Helpers and try asking on there.
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 11:54 AM
I'll try that then
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 12:51 PM
Bump
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 02:01 PM
Bumpppp again
Report Abuse
CorruptScript is online. CorruptScript
Joined: 16 Nov 2011
Total Posts: 3873
11 Dec 2016 02:29 PM
I tested my code and it worked perfectly, perhaps you forgot the click detector?


-The Time Traveling Knight of OT
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 02:56 PM
Nope the ClickDetector is definitely there.
Report Abuse
NyoJOSH is not online. NyoJOSH
Joined: 10 Sep 2012
Total Posts: 55
11 Dec 2016 03:35 PM
I've decided that I'm just gonna use a Gui instead. How do I clone a Gui from ServerStorage to PlayerGui using a part, localscript and clickdetector?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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