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 » Scripters
Home Search
 

Forgot how to roblox

Previous Thread :: Next Thread 
GunHeadProductions is not online. GunHeadProductions
Joined: 31 Mar 2011
Total Posts: 214
11 Mar 2016 04:34 PM
ay, been a while

Im making a script for fun, but it's being mean );

Output says: Workspace.lootSpawn.lootScript:18: bad argument #1 to 'new' (string expected, got nil)

Script says:

local possibleDrops = {}
local itemCount = 1

local storage = game.ReplicatedStorage
local dropPoint = script.Parent.Position

for i,v in pairs (storage:GetChildren()) do -- v will be the name of the item, and i will be the number of the item
possibleDrops[i] = v
print(possibleDrops[i])
end

function randomNumber ()
math.randomseed(tick())
local whichDrop = math.random(itemCount)

drop = storage:FindFirstChild(possibleDrops[whichDrop])

placement = Instance.new(drop, workspace)
placement.Position = dropPoint
end

game.Players.PlayerAdded:connect(randomNumber)

What's wrong? Thanks!
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
11 Mar 2016 04:38 PM
> placement = Instance.new(drop, workspace)

Instance.new expects the first argument to be a string corresponding to the type that you want the Instance to be, like "Part"

you probably want to use the Clone method on drop and then set its Parent value
btw, there's no 'possiblDrops[whichDrop]' in storage, i'd check that logic again

next time look at the wiki

Report Abuse
GunHeadProductions is not online. GunHeadProductions
Joined: 31 Mar 2011
Total Posts: 214
11 Mar 2016 04:42 PM
Doesn't: possibleDrops[i] = v

save the name of the object from storage (which would be a string) into possibleDrops?


#code --u guys r lame
Report Abuse
GunHeadProductions is not online. GunHeadProductions
Joined: 31 Mar 2011
Total Posts: 214
11 Mar 2016 04:54 PM
New Script with new issue:

Output: #code Workspace.lootSpawn.lootScript:20: attempt to call method 'Clone' (a nil value)

Code: #code

local possibleDrops = {}
local itemCount = 1

local storage = game.ReplicatedStorage
local dropPoint = script.Parent.Position

for i,v in pairs (storage:GetChildren()) do -- v will be the name of the item, and i will be the number of the item
possibleDrops[i] = v
print(possibleDrops[i])
end

function randomNumber ()
math.randomseed(tick())
local whichDrop = math.floor(math.random(itemCount))

dropString = storage:FindFirstChild(possibleDrops[whichDrop])

drop = tostring(dropString)

placement = drop:Clone()
placement.Parent = workspace
placement.Position = dropPoint
end

game.Players.PlayerAdded:connect(randomNumber)


Report Abuse
GunHeadProductions is not online. GunHeadProductions
Joined: 31 Mar 2011
Total Posts: 214
11 Mar 2016 04:55 PM
pardon the #codes, was testing R+ but im stupid


Report Abuse
os_time is not online. os_time
Joined: 15 Feb 2014
Total Posts: 2247
11 Mar 2016 04:59 PM
Wait
You are trying to clone a string?


http://lmgtfy.com/?q=Roblox+Wiki #code "Lua ~ PHP ~ CSS ~ HTML for me at least."
Report Abuse
GunHeadProductions is not online. GunHeadProductions
Joined: 31 Mar 2011
Total Posts: 214
11 Mar 2016 05:21 PM
No, I'm cloning an object (tool)


Report Abuse
GunHeadProductions is not online. GunHeadProductions
Joined: 31 Mar 2011
Total Posts: 214
11 Mar 2016 06:06 PM
bump


Report Abuse
GunHeadProductions is not online. GunHeadProductions
Joined: 31 Mar 2011
Total Posts: 214
12 Mar 2016 04:01 PM
bump


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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