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: If ___ is between __ and __

Previous Thread :: Next Thread 
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 07:48 PM
It doesnt seem to work when I use

    if Upgrade <= 332 and Upgrade ​>= 348 then

So what should I be using, or is it not possible?
Report Abuse
Heart0nFIRE is not online. Heart0nFIRE
Joined: 28 Oct 2011
Total Posts: 5623
09 Feb 2013 07:50 PM
if (Upgrade < 332) and (Upgrade > 348) then

--stuff
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 07:50 PM
Any output? What is 'Upgrade'?
Report Abuse
BJJScrambler is not online. BJJScrambler
Joined: 13 Jan 2013
Total Posts: 898
09 Feb 2013 07:52 PM
Your signs are backwards. It should be if Upgrade>=332 and Upgrade<=348 then
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 07:55 PM
Reversed the signs (my mistake)
still does not work. I don't want just ​> or < because im using
less than or equal to
and
more than or equal to
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 07:56 PM
forgot to say:
no output scripts works fine each click (gui)
and
Upgrade = math.random(1,100)
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 07:59 PM
Then there is your problem, you're checking for a value between 300-400 (or whatever it is) but you are only randomizing up to 100.
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 08:01 PM
Sorry I mixed to scripts up.
It is
if Upgrade ​>= 46 and Upgrade <= 52 then
with (1,100)


thoug the other script doesnt work with (1,400)
Report Abuse
BJJScrambler is not online. BJJScrambler
Joined: 13 Jan 2013
Total Posts: 898
09 Feb 2013 08:02 PM
Then maybe it is not in that range
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 08:03 PM
How many times are you firing this event? Remember, by using math.random there's like a 6/100 chance you're gonna get a number you want. :)
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 08:08 PM
I have fired it well over 200 times. I never got the output i wanted
Here is the whole script:

    Type = script.Parent.Parent.Parent.Stats.Type
    --Function
    function onbutton1down(mouse) do
    
    --Random Number Gens
    Upgrade = math.random(1,100)
    print("Upgrade = ".. Upgrade)
    
    --Script
    
        if Type.Value == "Epic" then
            if Upgrade <= 22 and Upgrade ​>= 21 then
                Type.Value = "Unique"
                print("NewUnique")
        elseif Type.Value == "Unique" then
        elseif Type.Value == "Rare" then
            if Upgrade ​>= 46 and Upgrade <= 52 then
                Type.Value = "Epic"
                print("NewEpic")
            else
                Type.Value = "Rare"
                print("SameRare")
        --Cube script
            end
            end
        end
    end
    end
    
    --Function
    script.Parent.MouseButton1Down:connect(onbutton1down)
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
09 Feb 2013 08:21 PM
Parenthesis is OPTIONAL when you use a if statement or a while loop.

----------


i liek pineapples.
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 08:22 PM
Just been playing around with the code, put an end there, but remove one off the bottom, seems to fix the problem I think you're having. :)

if Upgrade <= 22 and Upgrade ​>= 21 then
Type.Value = "Unique"
print("NewUnique")
end
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 08:30 PM
remove one what off the bottom? could uou post the whole script you are using?
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 08:32 PM
Type = script.Parent.Parent.Parent.Stats.Type
--Function
function onbutton1down(mouse) do

--Random Number Gens
Upgrade = math.random(1,100)
print("Upgrade = ".. Upgrade)

--Script

if Type.Value == "Epic" then
if Upgrade <= 22 and Upgrade ​>= 21 then
Type.Value = "Unique"
print("NewUnique")
end
elseif Type.Value == "Unique" then
elseif Type.Value == "Rare" then
if Upgrade ​>= 46 and Upgrade <= 52 then
Type.Value = "Epic"
print("NewEpic")
else
Type.Value = "Rare"
print("SameRare")
--Cube script
end
end
end
end

--Function
script.Parent.MouseButton1Down:connect(onbutton1down)
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 08:50 PM
So I manually changed Type.Value to "Epic" and the if that results in Unique works. I tried getting rid of the else statement but still nothing.
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 09:11 PM
OK so after changing it to just only if it is 1
when the number is one it STILL does not work.

I made the if then directly above it a note, and it works:

    Type = script.Parent.Parent.Parent.Stats.Type
    --Function
    function onbutton1down(mouse) do
    
    --Random Number Gens
    Upgrade = math.random(1,100)
    print("Upgrade = ".. Upgrade)
    
    --Script
    
        if Type.Value == "Epic" then
    --        if Upgrade <= 22 and Upgrade ​>= 21 then
    --            Type.Value = "Unique"
    --            print("Unique")
        elseif Type.Value == "Rare" then
            if Upgrade ​>= 46 and Upgrade <= 52 then
                Type.Value = "Epic"
                print("Epic")
            elseif Upgrade <= 45 or Upgrade ​>= 53 then
                Type.Value = "Rare"
                print("Rare")
        elseif Type.Value == "Unique" then
    
        --Stats script
            end
    --        end
        end
    end
    end
    
    --Function
    script.Parent.MouseButton1Down:connect(onbutton1down)
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 09:15 PM
Can you explain what you want to do, I'll rewrite you some code...
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 09:19 PM
A bit complicated but..

-The value will always start out as "Rare"
-Will lead to more code
-Is triggered by GuiClicks (if this matters at all)

If the value is "Rare" I want it to upgrade to "Epic" at a 6% chance
Once it is "Epic" I want it to upgrade to "Unique" at a 2% chance
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 09:24 PM
Try this:

local Type = script.Parent.Parent.Parent.Stats.Type

script.Parent.MouseButton1Down:connect(function()
local Upgrade = math.random(1,100)
print ("Upgrade: "..Upgrade)
if Type.Value == "Rare" then
if Upgrade >= 46 and Upgrade <= 52 then
Type.Value = "Epic"
end
elseif Type.Value == "Epic" then
if Upgrade <=21 and Upgrade >= 22 then
Type.Value = "Unique"
end
end
end)
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 09:31 PM
Tried that but then the Unique one stops working :/
I don't understand why the second if then does not work...
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 11:29 PM
It is as if it ignores all the if...then statements except the first one
Report Abuse
ashispro is not online. ashispro
Joined: 14 Sep 2008
Total Posts: 452
09 Feb 2013 11:33 PM

local Type = script.Parent.Parent.Parent.Stats.Type

script.Parent.MouseButton1Down:connect(function()
local Upgrade = math.random(1,100)
print ("Upgrade: "..Upgrade)
if Type.Value == "Rare" then
if Upgrade >= 46 and Upgrade <= 52 then
Type.Value = "Epic"
end
end
if Type.Value == "Epic" then
if Upgrade <=21 and Upgrade >= 22 then
Type.Value = "Unique"
end
end
if Type.Value == "Unique" then return end
end)

only other thing i can think of
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 11:40 PM
It works!
but now since it says end, will it still execute script that comes after the statemyents?
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
09 Feb 2013 11:41 PM
Nevermind, I made an output but
could you briefly explain
WHY it doesnt end the script?
Thanks
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