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
 

Re: While true do.

Previous Thread :: Next Thread 
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 07:49 AM
while true do
script.Parent.CFrame = CFrame.new(179, script.Parent.Position.y + 0.1, 167.5)
wait(script.Parent.Value.Value)
end




Would I have to make a variable to make it wait the value?
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
14 Dec 2011 08:05 AM
No. That looks like it will work.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:07 AM
Didn#t though D;
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
14 Dec 2011 08:08 AM
What's the output say?

(View ​> Output) if you don't have it open.
The error should be in red.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:09 AM
Well, I think the problem is, my other script makes the value 0.0125, but the value goes to 0.01250000001 automatically.
Report Abuse
Raven5887 is not online. Raven5887
Joined: 08 Dec 2008
Total Posts: 3184
14 Dec 2011 08:09 AM
What output do you get?

Most likely one of the paths you use return nil
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:10 AM
No no, at the beginning the value is 0.025, and when the message comes out(I made a message with it), I can see the message, but the lava stays at it's normal speed.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:11 AM
And nothing shows up in the output.
Report Abuse
Raven5887 is not online. Raven5887
Joined: 08 Dec 2008
Total Posts: 3184
14 Dec 2011 08:13 AM
Why would the value of script.Parent.Value.Value change?

Because that is your problem then, this script's syntax is fine.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:14 AM
WHat you mean? In play solo the value changes, I see it.
Report Abuse
Raven5887 is not online. Raven5887
Joined: 08 Dec 2008
Total Posts: 3184
14 Dec 2011 08:15 AM
Thats odd, and 'Value' is a NumberValue inside the same parent as the script?
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:16 AM
The value is a numbervalue.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:17 AM
And yes, same parent.
Report Abuse
Raven5887 is not online. Raven5887
Joined: 08 Dec 2008
Total Posts: 3184
14 Dec 2011 08:19 AM
Try this:

local lava = script.Parent
local lavaOrgPosition = lava.Position
local waitTime = script.Parent.Value

local additionY = 0

while wait(waitTime.Value) do
additionY = additionY +.1
lava .CFrame = CFrame.new( lavaOrgPosition + Vector3.new(0,additionY ,0) )
end
Report Abuse
Raven5887 is not online. Raven5887
Joined: 08 Dec 2008
Total Posts: 3184
14 Dec 2011 08:20 AM
Oops, little typo: space between lava and .cframe shoudl be gone
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:21 AM
This was the script I made with variables:

t = script.Parent.Value

while true do
script.Parent.CFrame = CFrame.new(179, script.Parent.Position.y + 0.1, 167.5)
wait(t.Value)
end


Pretty much the same, but nothing happened either.
Report Abuse
Raven5887 is not online. Raven5887
Joined: 08 Dec 2008
Total Posts: 3184
14 Dec 2011 08:26 AM
Well it should work, you must be doing something wrong. Your not changing the wrong value or something like that? :P

Stuff like that happens the best
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:26 AM
Oh nvm I'll just leave it out.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:29 AM
Zomg I has an idea!

If I say

Value.Value = 125

And then in the other script

wait(t / 10000)

Well, I think that'll make 0.0125. Gonna use command bar.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:30 AM
Nonono

wait(math.floor(t / 10000))
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
14 Dec 2011 08:31 AM
It's a floating point error. How you do the math won't make a difference, the issue is that a floating point number can never _exactly_ represent the quantity you're trying to represent.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:32 AM
So nothing would work?
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
14 Dec 2011 08:36 AM
Exactly. However, it shouldn't make a difference. The noise on how long a wait is (wait can be anything like, +-0.005 seconds or so) is far greater than any difference that would make.

Also, I would write the CFrame change like this:
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0.1, 0)

That will "add" 0.1 studs upwards to the position of the CFrame, upwards being the way the top of the part is facing. On the other hand if you want it to go straight up regardless of what way it's facing:
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, 0.1, 0)
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
14 Dec 2011 08:38 AM
My other script works too, it's only the speed that isn't cooperating.
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
14 Dec 2011 08:40 AM
If you really require a constant speed you can do this:

local lastTime = tick()
while true do
local now = tick()
local timePassed = now-lastTime
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, 10*timePassed, 0)
lastTime = now
end

That will force it to move at exactly 10 studs per second regardless of what happens with the game's timing.
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