DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 07:42 AM |
Can someone fix this script for me? It wont work.
model = script.Parent.Parent part = script.Parent
function onTouch(hit) if hit.Parent.Humanoid then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local char = plr.Character local humanoid = char:FindFirstChild('Humanoid') if humanoid then model:Clone() model.CFrame = model.CFrame * CFrame.new(24,0,0) end end end
script.Parent.Touched:connect(onTouch)
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 07:46 AM |
By it doesn't work I mean it doesn't clone the model then move it.
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 26 Sep 2016 07:50 AM |
if 'model' refers to an actual "Model" then you can't use CFrame on it You should use model:MoveTo(Vector3) |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 07:50 AM |
| models don't have a frame property. set a primary part |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 07:50 AM |
Oh okay, (Vector3.new)?
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 07:51 AM |
| damn autocorrect. frame should be cframe. |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 07:52 AM |
Would I use (Vector3.new(24,0,0)?
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 07:54 AM |
| model:MoveTo(model.Position + Vector3.new(24, 0, 0)) |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 07:55 AM |
| Oops, models don't have positions. But you get what I mean. |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 07:55 AM |
Thanks I'm new to scripting, and very new to Vectors, so I am learning.
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 07:58 AM |
I put in (Vector3.new(1,0,0)) and it's teleporting the player as well, how can I fix this?
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 08:00 AM |
It's not cloning ,thats the problem. Why is't it cloning? Isn't model:Clone() how you duplicate things.
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 26 Sep 2016 08:19 AM |
For:
model:Clone() model.Parent
You're cloning the original and changing the parent of the original, not the clone
newmodel = model:Clone() newmodel.Parent = |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 08:23 AM |
Nagrath, I don't have model.Parent anywhere in my script????
I'm fairly new to lua coding, so please explain a bit more?
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 26 Sep 2016 08:24 AM |
Create a variable for the original - newmodel = model:clone() Move the newly cloned model - newmodel:MoveBy(Vector3) Set the parent of the moved model - newmodel.Parent =
|
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 08:26 AM |
model = script.Parent.Parent part = script.Parent
function onTouch(hit) if hit.Parent.Humanoid then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local char = plr.Character local humanoid = char:FindFirstChild('Humanoid') if humanoid then local mm = model:Clone() mm.Parent = workspace mm:MoveTo(Vector3.new(somewhere over the rainbow) end end end
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 08:29 AM |
When the model is cloned, does it clone in the same spot as the old model?
Basically I'm trying to make an infinite hallway, and a section of the hallway clones each time a part in the model is touched.
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
| |
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 08:31 AM |
How would I go about doing this then?
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 08:33 AM |
so I would set a primary part. and then do this thingy I guess.
local lastHall = woohoo local newH = lastHall:Clone() newH.Parent = game.Workspace newH:MoveTo(Vector3.new(lastHall.Position + lengthOfHallway))
obviously you'll need to add more though, but you get the idea. if the hallway was 5 studs it'd be lastHall.Position + Vector3.new(0, 0, 5) |
|
|
| Report Abuse |
|
|
DevObject
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 7048 |
|
|
| 26 Sep 2016 08:36 AM |
Oh okay, thanks :) I will try
Lol'd >Add 5k posts, R.I.P. ROBLOXBaseWarsFPS1 |
|
|
| Report Abuse |
|
|