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
 

Cloning out of lighting

Previous Thread :: Next Thread 
HannoBarca is not online. HannoBarca
Joined: 20 Aug 2012
Total Posts: 509
04 Oct 2013 06:28 AM
So, I clone a ship out of lighting when a player with over 20 KOs hits a brick. It works, but the ship falls apart. Any ideas why?

Script:
local Door = script.Parent
local debounce = false

function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouched(hit)
if debounce == false then
local human = hit.Parent:findFirstChild("Humanoid")
if (human == nil) then return end
local player = getPlayer(human)
debounce = true
if (player == nil) then return end
local stats = player:findFirstChild("leaderstats")
local ko = stats:findFirstChild("KOs")
if ko == nil then return false end
if (ko.Value >=20) then
ko.Value = ko.Value - 20
print("Enough Money")
game.Lighting.Ship:clone().Parent = game.Workspace
script.Disabled = true
wait(2)
script.Disabled = false
debounce = false
else debounce = false
end
end

end

connection = Door.Touched:connect(onTouch)


Any reasons why the boat wouldn't work?
- Not anchored, but all welded together. When I just had it in workpace, not cloning it from lighting, it worked fine.
Report Abuse
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
04 Oct 2013 06:31 AM
local Door = script.Parent
local debounce = false

function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouched(hit)
if debounce == false then
local human = hit.Parent:findFirstChild("Humanoid")
if (human == nil) then return end
local player = getPlayer(human)
debounce = true
if (player == nil) then return end
local stats = player:findFirstChild("leaderstats")
local ko = stats:findFirstChild("KOs")
if ko == nil then return false end
if (ko.Value >=20) then
ko.Value = ko.Value - 20
print("Enough Money")
zi = game.Lighting.Ship
zi.Parent = game.Workspace
zi:MakeJoints()
script.Disabled = true
wait(2)
script.Disabled = false
debounce = false
else debounce = false
end
end

end

connection = Door.Touched:connect(onTouch)
Report Abuse
Project2015 is not online. Project2015
Joined: 11 Sep 2013
Total Posts: 384
04 Oct 2013 06:48 AM
local Door = script.Parent
local debounce = false

function getPlayer(humanoid)
local players = game.Players:GetChildren()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouched(hit)
if debounce == false then
local human = hit.Parent:findFirstChild("Humanoid")
if (human == nil) then return end
local player = getPlayer(human)
debounce = true
if (player == nil) then return end
local stats = player:findFirstChild("leaderstats")
local ko = stats:findFirstChild("KOs")
if ko == nil then return false end
if (ko.Value >=20) then
ko.Value = ko.Value - 20
print("Enough Money")
zi = game.Lighting.Ship:clone() -- You forgot clone
zi.Parent = game.Workspace
zi:MakeJoints()
script.Disabled = true
wait(2)
script.Disabled = false
debounce = false
else debounce = false
end
end

end

Door.Touched:connect(onTouch)
Report Abuse
Project2015 is not online. Project2015
Joined: 11 Sep 2013
Total Posts: 384
04 Oct 2013 06:49 AM
Clone and MakeJoints
Report Abuse
HannoBarca is not online. HannoBarca
Joined: 20 Aug 2012
Total Posts: 509
04 Oct 2013 06:56 AM
Doesn't seem to clone when touched now.
Report Abuse
Project2015 is not online. Project2015
Joined: 11 Sep 2013
Total Posts: 384
04 Oct 2013 07:09 AM
Cloned but not at the position?
Report Abuse
HannoBarca is not online. HannoBarca
Joined: 20 Aug 2012
Total Posts: 509
04 Oct 2013 07:16 AM
Nope.

Output (Paraphrased because I'm on phone)

Attempted to access a nil value
Disconnected because of exception

--------------
I think that's right.
When I get home ill do more testing though.
Report Abuse
ProjectsHidden is not online. ProjectsHidden
Joined: 29 Sep 2013
Total Posts: 194
04 Oct 2013 07:23 AM
pastebin
.
com
/6AKeetZA
Report Abuse
HannoBarca is not online. HannoBarca
Joined: 20 Aug 2012
Total Posts: 509
04 Oct 2013 02:33 PM
15:32:12.754 - attempt to call a nil value
15:32:12.756 - Disconnected event because of exception
That's the output.

@above
That was removed, can't view it.
Anything else?
Report Abuse
HannoBarca is not online. HannoBarca
Joined: 20 Aug 2012
Total Posts: 509
04 Oct 2013 04:43 PM
Bump
Report Abuse
madattak9 is not online. madattak9
Joined: 30 Aug 2008
Total Posts: 244
04 Oct 2013 05:49 PM
Normally I build my models anchored and unwelded, then use a welding script or CmdUtl. Doing the same in future may be helpful for you. No, I don't know how to make a welding script.
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
04 Oct 2013 05:51 PM
"15:32:12.754 - attempt to call a nil value
15:32:12.756 - Disconnected event because of exception"

This means that you are using connect on a nil function.
Functions are case sensitive. Make sure the function you are calling matches the actual name of the function.
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