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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 11 Dec 2016 10:44 AM |
Np.
-The Time Traveling Knight of OT |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 10 Sep 2012 |
| Total Posts: 55 |
|
|
| 11 Dec 2016 10:52 AM |
| Alright will do this to, thanks. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 10 Sep 2012 |
| Total Posts: 55 |
|
|
| 11 Dec 2016 11:15 AM |
| Just as I imagined, didn't work. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 10 Sep 2012 |
| Total Posts: 55 |
|
| |
|
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
|
  |
| Joined: 10 Sep 2012 |
| Total Posts: 55 |
|
| |
|
NyoJOSH
|
  |
| Joined: 10 Sep 2012 |
| Total Posts: 55 |
|
| |
|
NyoJOSH
|
  |
| Joined: 10 Sep 2012 |
| Total Posts: 55 |
|
| |
|
|
| 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
|
  |
| Joined: 10 Sep 2012 |
| Total Posts: 55 |
|
|
| 11 Dec 2016 02:56 PM |
| Nope the ClickDetector is definitely there. |
|
|
| Report Abuse |
|
|
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 |
|
|