|
| 07 Jan 2015 02:37 AM |
So I am making a wall charge that, when clicked, will retract into the frame. This is what I have so far
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local sp = script.Parent
local x, y, z = sp.x, sp.y, sp.z local i = sp.z function Detonate() while i > i + 0.200 do i = i + 0.020 sp = Vector3.new(sp.x, sp.y, i) end end script.Parent.ClickDetector.MouseClick:connect(Detonate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The coordinate I am trying to change is the z value which is -85.695. When the player clicks I want the Z value to be -85.495, hence the "while i < i + 0.200 do" I then make i (the z-value) = i + 0.020 or -85.695 = -85.695 + 0.020
then script.Parent's (the part I want moved) Vector3 = (the current x, the current y, i)
When I test it in game, it doesn't work. The output is ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00:24:45.679 - x is not a valid member of Part 00:24:45.680 - Script 'Workspace.Wall Charge.Explosives.Script', Line 3 00:24:45.680 - Stack End ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I am unsure if the "x is not a valid member of Part" is part of the script because script.Parent = Explosives
Any help would be appreciated, thanks!
|
|
|
| Report Abuse |
|
|
| |
|
goro7
|
  |
| Joined: 01 Jul 2009 |
| Total Posts: 735 |
|
|
| 07 Jan 2015 12:16 PM |
| Make sure you are doing the sp.Position = Vector3.new(blah,blah,blah) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 07 Jan 2015 12:30 PM |
The position is stored in the Position property as a Vector3 value. You're best off using CFrame if you need it to clip. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2015 12:56 PM |
| Okay I so tried using Cframe, same result. Nothing happens. Is it possible that the clicks aren't registering |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2015 12:56 PM |
Btw here is the code
local sp = script.Parent function Detonate() sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) wait(0.1) sp.CFrame = sp.Cframe + Vector3.new(0,0,0.020) end script.Parent.ClickDetector.MouseClick:connect(Detonate) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 07 Jan 2015 01:01 PM |
You just moved it like .2 Dude are you familiar with the word 'loop'? |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2015 01:04 PM |
| I am familiar with loops but I am not very good at scripting. I feared that I was making my loop wrong and that was breaking it, so I just took the easy approach for now. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2015 01:10 PM |
How is this?
local sp = script.Parent function Detonate() print("Clicked!") local i = 0 while i < 10 do sp.Cframe = sp.Cframe + Vector3.new(0,0,0.020) i = i +1 end end script.Parent.ClickDetector.MouseClick:connect(Detonate) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 07 Jan 2015 01:14 PM |
I'd have done
while i < 1 do i=i+wait(); script.Parent.CFrame = script.Parent.CFrame*Vector3.new(0,0,0.08) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 07 Jan 2015 01:15 PM |
Just, uhh With an end.
Jeez I need to stop here like really I can't do anything right ;-; |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2015 01:17 PM |
| Aha I got it to work with what I posted. But with you script, why did you do i = i+wait() ? What does that do? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|