hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 02:51 AM |
Just as the title says, am I making it right? I'm trying to let the player choose only 1 primary weapon (As you can tell), I have the thing that puts the values into the player all set up correctly, but for some reason, I can't get this to work, please help!
function onTouch(hit) if hit.Parent.Prim.Value == false then local hitName = hit.Parent.Name local wep = game.Lighting.AK47:Clone() wep.Parent = game.Players.hitName.Backpack hit.Parent.Prim.Value = true hit.Parent.Humanoid.Health = 1 end end
script.Parent.Giver.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 02:52 AM |
| Please note that I did include the TABs and everything, it just doesn't show up on the forum post. |
|
|
| Report Abuse |
|
|
hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 02:55 AM |
| Oh yes, also, don't mind that set health part, it was just a test. |
|
|
| Report Abuse |
|
|
zakary99
|
  |
| Joined: 19 Jan 2010 |
| Total Posts: 1095 |
|
|
| 10 Apr 2013 04:22 AM |
Wouldn't you be using hit.Name? not hitName.
I admit my scripting skills are rusty. |
|
|
| Report Abuse |
|
|
hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 04:26 AM |
No, because hitName is a variable, as you can see when it says: wep.Parent = game.Players.hitName.Backpack -------------------^^^^^^^^^^ |
|
|
| Report Abuse |
|
|
zakary99
|
  |
| Joined: 19 Jan 2010 |
| Total Posts: 1095 |
|
|
| 10 Apr 2013 04:27 AM |
| Oh yeah didn't see that line, what is your output when you try to use it? |
|
|
| Report Abuse |
|
|
hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 04:45 AM |
| My output? Well... Nothing happens... :U |
|
|
| Report Abuse |
|
|
zakary99
|
  |
| Joined: 19 Jan 2010 |
| Total Posts: 1095 |
|
|
| 10 Apr 2013 06:32 AM |
Client or Server?
~You have to think like a Dinosaur to become a Dinosaur~ |
|
|
| Report Abuse |
|
|
mark298
|
  |
| Joined: 24 Oct 2008 |
| Total Posts: 1264 |
|
|
| 10 Apr 2013 06:35 AM |
function onTouch(hit) if hit.Parent.Prim.Value == false then local hitName = hit.Parent.Name local wep = game.Lighting.AK47:Clone() wep.Parent = game.Players:FindFirstChild(hitName).Backpack hit.Parent.Prim.Value = true hit.Parent.Humanoid.Health = 1 end end
script.Parent.Giver.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 04:03 PM |
@Mark298 Oh, I've never tried that, I'll try it, thanks. |
|
|
| Report Abuse |
|
|
hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 04:12 PM |
| That didn't work, I think the problem here is cause to the game it thinks it's trying to go to "game.PlayersPlayer1.Backpack" (Player1 is the solo player name), it's trying to do that because there is no dot. What I'm looking for it to go to is: "game.Players.Player1.Backpack" |
|
|
| Report Abuse |
|
|
hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 04:15 PM |
| Oh wait! Nevermind! It's working now! Yay! |
|
|
| Report Abuse |
|
|
hudzell
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 41 |
|
|
| 10 Apr 2013 04:16 PM |
Here is the code that I used: function onTouch(hit) if hit.Parent.Prim.Value == false then local hitName = hit.Parent.Name local wep = game.Lighting.AK47:Clone() wep.Parent = game.Players:findFirstChild(hitName).Backpack hit.Parent.Prim.Value = true end end
script.Parent.Giver.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
mark298
|
  |
| Joined: 24 Oct 2008 |
| Total Posts: 1264 |
|
|
| 11 Apr 2013 04:15 AM |
All you did was get rid of this line:
"hit.Parent.Humanoid.Health = 1" |
|
|
| Report Abuse |
|
|