|
| 25 Oct 2013 07:59 PM |
function selectWeapon() possibleWeapons = {game.Lighting.Weapons:GetChildren()}
randomizedSelection = math.random(1,#possibleWeapons)
randomizedChoice = possibleWeapons[randomizedSelection]
return randomizedChoice
end
function giveWeapon(weapon) weaponClone = weapon:clone() --ERRORED ON THIS LINE weaponClone.Parent = game.Players.Player1 end
--When it's bought giveWeapon(selectWeapon) --end
----------------------------------------------------------- CODE END -----------------------------------------------------------
Output says that I tried to reparent a 'function value'.
Can anybody tell me what I've done wrong?
|
|
|
| Report Abuse |
|
|
|
| 25 Oct 2013 08:02 PM |
Weapon = selectWeapon()
giveWeapon(Weapon)
http://www.roblox.com/My/Groups.aspx?gid=66545 |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2013 08:11 PM |
weaponclone = [item]:clone() [item].Parent = [EX: game.Workspace] |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2013 09:38 PM |
My script is now:
-------------------------------- CODE START --------------------------------
function selectWeapon() possibleWeapons = {game.Lighting.Weapons:GetChildren()}
randomizedSelection = math.random(1,#possibleWeapons)
randomizedChoice = possibleWeapons[randomizedSelection]
return randomizedChoice
end
function giveWeapon(weapon) print(weapon.Name) weaponClone = weapon:clone() weaponClone.Parent = game.Players.Player1 end
Weapon = selectWeapon()
--When it's bought giveWeapon(Weapon) --end
-------------------------------- CODE END --------------------------------
But now it prints out nil before erroring.
It's error is trying to clone a nil object... |
|
|
| Report Abuse |
|
|
|
| 25 Oct 2013 09:41 PM |
function selectWeapon() possibleWeapons = {game.Lighting.Weapons:GetChildren()} randomizedSelection = math.random(1,#possibleWeapons) randomizedChoice = possibleWeapons[randomizedSelection] return randomizedChoice end
function giveWeapon() Weapon = selectWeapon() print(Weapon) WeaponClone = Weapon:Clone() WeaponClone.Parent = game.Players.Player1 end
giveWeapon()
http://www.roblox.com/My/Groups.aspx?gid=66545 |
|
|
| Report Abuse |
|
|