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 » Scripters
Home Search
 

Re: Moving a block with Vector3 and a loop, not working.

Previous Thread :: Next Thread 
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
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
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
07 Jan 2015 12:15 PM
Bump
Report Abuse
goro7 is not online. 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 is not online. 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
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
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
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
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 is not online. 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
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
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
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
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 is not online. 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 is not online. 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
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
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 is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
07 Jan 2015 01:21 PM
DeltaTime
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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