Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
|
| 29 Apr 2017 04:33 PM |
So I made this script where whenever a player clicks a brick, a knife would be awarded to that player. However, it's saying that the model that stores all of the tools doesn't exist, even though it's right there. Any idea why this isn't working? Here's the script:
function onClicked(playerWhoClicked) workspace.tools.knoife:Clone().Parent = playerWhoClicked end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
|
| 29 Apr 2017 04:45 PM |
playerWhoClicked.Backpack?
idk try that
ok |
|
|
| Report Abuse |
|
|
Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
|
| 29 Apr 2017 04:48 PM |
no, it's not playerWhoClicked, it's the fact that tools is in workspace but it's saying that it's not in workspace.
|
|
|
| Report Abuse |
|
|
Henderick
|
  |
| Joined: 10 Dec 2007 |
| Total Posts: 1523 |
|
|
| 29 Apr 2017 04:48 PM |
| did you intentionally name your knife "kniof" |
|
|
| Report Abuse |
|
|
Henderick
|
  |
| Joined: 10 Dec 2007 |
| Total Posts: 1523 |
|
| |
|
Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
| |
|
|
| 29 Apr 2017 04:50 PM |
is there a typo somewhere?
ok |
|
|
| Report Abuse |
|
|
Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
| |
|
Dev_Cos
|
  |
| Joined: 22 Oct 2016 |
| Total Posts: 83 |
|
|
| 29 Apr 2017 05:11 PM |
| Try putting game in front of workspace maybe? |
|
|
| Report Abuse |
|
|
Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
|
| 29 Apr 2017 05:13 PM |
i've done that, doesn't work
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 29 Apr 2017 05:14 PM |
You're parenting it to the player parent it to the player's backpack, or their character if they don't already have a tool equipped. |
|
|
| Report Abuse |
|
|
Dev_Cos
|
  |
| Joined: 22 Oct 2016 |
| Total Posts: 83 |
|
|
| 29 Apr 2017 05:16 PM |
Maybe when the player is added it the tool hasnt fully loaded.
|
|
|
| Report Abuse |
|
|
Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
|
| 29 Apr 2017 05:23 PM |
still not working? i think i'm doing something wrong, here's the script
function onClicked(playerWhoClicked) workspace.tools.knoife:Clone().Parent = playerWhoClicked.Backpack end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 29 Apr 2017 08:26 PM |
| Just open your output and give us the error |
|
|
| Report Abuse |
|
|
Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 29 Apr 2017 08:31 PM |
| workspace.tools doesn't exist when the script runs |
|
|
| Report Abuse |
|
|
Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
|
| 29 Apr 2017 08:32 PM |
it does exist. it's not called in through instance.new or anything
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 29 Apr 2017 08:35 PM |
It doesn't exist, that's what your error means. Read what I said carefully, it doesn't exist -> when the script runs <-
Though it might exist later. say tools = workspace:WaitForChild("tools")
And please use better variable names |
|
|
| Report Abuse |
|
|
Reziztor
|
  |
| Joined: 08 Jul 2014 |
| Total Posts: 67 |
|
|
| 29 Apr 2017 09:01 PM |
turns out the real reason why it kept on erroring me is because the knife wasn't on the baseplate, unanchored, and kept falling into nonexistence
aha...ha...
kill me
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 29 Apr 2017 10:06 PM |
| You should put it somewhere like ReplicatedStorage |
|
|
| Report Abuse |
|
|