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 » Scripting Helpers
Home Search
 

Re: Am I making this giver script right?

Previous Thread :: Next Thread 
hudzell is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. hudzell
Joined: 14 Jul 2011
Total Posts: 41
10 Apr 2013 04:45 AM
My output? Well... Nothing happens... :U
Report Abuse
zakary99 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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