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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: What's wrong with this script?

Previous Thread :: Next Thread 
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
03 Aug 2013 06:21 AM
function ontouched()
rand = math.random(1,3)
if rand == 1 then
game.Lighting.Dark:clone()
clone.Parent = Workspace
clone.Posistion = Workspace.Baseplate.Position.Vector3.new(0, 5, 0)
end
end

function ontouched()
rand = math.random(1,3)
if rand == 2 then
game.Lighting.Light:clone()
clone.Parent = Workspace
clone.Posistion = Workspace.Baseplate.Position.Vector3.new(0, 5, 0)
end
end



function ontouched()
rand = math.random(1,3)
if rand == 3 then
game.Lighting.Medium:clone()
clone.Parent = Workspace
clone.Posistion = Workspace.Baseplate.Position.Vector3.new(0, 5, 0)
wait()
end
end

script.Parent.Part.Touched:connect(ontouched)
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
03 Aug 2013 06:25 AM
bump
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
03 Aug 2013 06:34 AM
blump
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
03 Aug 2013 06:40 AM
clone* isn't a model or a variable. You said clone.Parent.. And clone.Position.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
03 Aug 2013 06:55 AM
Instead of:
game.Lighting.Light:clone()
clone.Parent = Workspace
Do this
TheClone = game.Lighting.Light:Clone()
TheClone.Parent = game.Workspace
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
03 Aug 2013 06:58 AM
Yeah I knew that but this doesn't work:

function ontouched()
rand = math.random(1,3)
if rand == 1 then
game.Lighting.Dark:clone()
Dark.Parent = Workspace
Dark.Posistion = Workspace.Baseplate.Position.Vector3.new(0, 5, 0)
end
end

function ontouched()
rand = math.random(1,3)
if rand == 2 then
game.Lighting.Light:clone()
Light.Parent = Workspace
Light.Posistion = Workspace.Baseplate.Position.Vector3.new(0, 5, 0)
end
end



function ontouched()
rand = math.random(1,3)
if rand == 3 then
game.Lighting.Medium:clone()
Medium.Parent = Workspace
Medium.Posistion = Workspace.Baseplate.Position.Vector3.new(0, 5, 0)
wait()
end
end

script.Parent.Part.Touched:connect(ontouched)
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
03 Aug 2013 06:59 AM
Medium, Light, and Dark isn't a variable.
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
03 Aug 2013 07:00 AM
You misspelled position.
Report Abuse
thetacah is not online. thetacah
Joined: 18 Jan 2013
Total Posts: 16026
03 Aug 2013 07:04 AM
No Medium, Light and Dark are the Parts i'm cloning! And I didn't misspell Position
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
03 Aug 2013 07:07 AM
You`re doing it wrong You cloned the part but didn`t set the clone as a variable.
First you declare a variable then hook it to the clone like this:
clone = part:Clone()
Then you can change it`s properties like so:
clone.Parent = game.Workspace
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
03 Aug 2013 07:08 AM
You said "Posistion". And you have to put a variable for the parts you're cloning or it won't work. Dark = [Model]:Clone()
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
03 Aug 2013 07:09 AM
@OP,
1) Yes, you did spell 'Position' incorrectly. You spelt it 'Posistion'. (E.g. Dark.Posistion)
2) Yes, while it may be that they're called whatever, it's not a variable within the script.
3) That is not how you add positions.
4) Remember there's an output window.

-----

function ontouched()
rand = math.random(1,3)
local Selected = rand == 1 and game.Lighting.Dark:Clone() or rand == 2 and game.Lighting.Light:Clone() or rand == 3 and game.Lighting.Medium:Clone()
Selected.Parent = Workspace
Selected.Position = Workspace.Baseplate.Position + Vector3.new(0,5,0)
end
script.Parent.Part.Touched:connect(ontouched)

Or, if you want it you way...

function ontouched()
rand = math.random(1,3)
if rand == 1 then
Selected = game.Lighting.Dark:Clone()
elseif rand == 2 then
Selected = game.Lighting.Light:Clone()
elseif rand == 3 then
Selected = game.Lighting.Medium:Clone()
end
Selected.Parent = Workspace
Selected.Position = Workspace.Baseplate.Position + Vector3.new(0,5,0)
end
script.Parent.Part.Touched:connect(ontouched)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
03 Aug 2013 07:20 AM
Ohh, I didn`t even look at the positions -Derp-
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