|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 04 Oct 2013 06:56 AM |
| Doesn't seem to clone when touched now. |
|
|
| Report Abuse |
|
|
|
| 04 Oct 2013 07:09 AM |
| Cloned but not at the position? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|