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
 

WHY WON'T THIS WORK???

Previous Thread :: Next Thread 
Randy_Moss is not online. Randy_Moss
Joined: 05 Aug 2009
Total Posts: 30511
05 Jun 2016 03:01 PM
Cards = {425693490,425702520,425703997,425704061,425704795,425705486}

local Imagelabel1 = script.Parent.ScreenGui.CardFrame.ImageButton
local Imagelabel2 = script.Parent.ScreenGui.CardFrame2.ImageButton

Imagelabel1.Image = Cards[math.random(1, #Cards)]
Imagelabel2.Image = Cards[math.random(1, #Cards)]

Imagelabel1.Image = "rbxassetid://"..Cards
Imagelabel2.Image = "rbxassetid://"..Cards


It just leaves the image blank.
Report Abuse
xThe_Developer is not online. xThe_Developer
Joined: 07 Aug 2013
Total Posts: 585
05 Jun 2016 03:03 PM
Cards = {425693490,425702520,425703997,425704061,425704795,425705486}

local Imagelabel1 = script.Parent.ScreenGui.CardFrame.ImageButton
local Imagelabel2 = script.Parent.ScreenGui.CardFrame2.ImageButton

math.randomseed(6)
Im1 = Cards[math.random(1, #Cards)]
Im2 = Cards[math.random(1, #Cards)]

Imagelabel1.Image = "rbxassetid://"..tostring(Im1)
Imagelabel2.Image = "rbxassetid://"..tostring(Im2)


#code mod = require(sike) if not mod.xThe[...] then print("You're not RbxDev yet..") end
Report Abuse
Randy_Moss is not online. Randy_Moss
Joined: 05 Aug 2009
Total Posts: 30511
05 Jun 2016 03:06 PM
thanks! But how come when I click test it gives me the same card over and over
Report Abuse
xThe_Developer is not online. xThe_Developer
Joined: 07 Aug 2013
Total Posts: 585
05 Jun 2016 03:07 PM
play around with the name in randomseed
change it to something like
math.randomseed(math.random(1,math.random()))


#code mod = require(sike) if not mod.xThe[...] then print("You're not RbxDev yet..") end
Report Abuse
Randy_Moss is not online. Randy_Moss
Joined: 05 Aug 2009
Total Posts: 30511
05 Jun 2016 03:08 PM
I added more images and it broke :/
Cards = {425693490,425702520,425703997,425704061,425704795,425705486}

local Imagelabel1 = script.Parent.ScreenGui.CardFrame.ImageButton
local Imagelabel2 = script.Parent.ScreenGui.CardFrame2.ImageButton
local Imagelabel3 = script.Parent.ScreenGui.CardFrame3.ImageButton
local Imagelabel4 = script.Parent.ScreenGui.CardFrame4.ImageButton

math.randomseed(12)
Im1 = Cards[math.random(1, #Cards)]
Im2 = Cards[math.random(1, #Cards)]
Im3 = Cards[math.random(1, #Cards)]
Im4 = Cards[math.random(1, #Cards)]

Imagelabel1.Image = "rbxassetid://"..tostring(Im1)
Imagelabel2.Image = "rbxassetid://"..tostring(Im2)
Imagelabel3.Image = "rbxassetid://"..tostring(Im3)
Imagelabel4.Image = "rbxassetid://"..tostring(Im4)
Report Abuse
xThe_Developer is not online. xThe_Developer
Joined: 07 Aug 2013
Total Posts: 585
05 Jun 2016 03:13 PM
math.randomseed(math.random())
Cards = {425693490,425702520,425703997,425704061,425704795,425705486}

local par = script.Parent
local gui = par.ScreenGui
local CardFrames={}

for i,v in next, (gui:GetChildren()) do
if v.Name:match("CardFrame") then
table.insert(CardFrames,v)
end
end

for i,v in next, (CardFrames) do
local Image = Cards[math.random(1, #Cards)]
local ImageButton = v:FindFirstChild("ImageButton",true)
if ImageButton then
ImageButton.Image = 'rbxassetid://'..tostring(Image)
end
end


#code mod = require(sike) if not mod.xThe[...] then print("You're not RbxDev yet..") end
Report Abuse
Randy_Moss is not online. Randy_Moss
Joined: 05 Aug 2009
Total Posts: 30511
05 Jun 2016 03:14 PM
O I see what I did wrong. Thanks.

But I am still confused on how to make it more random :/
Report Abuse
xThe_Developer is not online. xThe_Developer
Joined: 07 Aug 2013
Total Posts: 585
05 Jun 2016 03:15 PM
math.randomseed makes the number math.random generates more random.


#code mod = require(sike) if not mod.xThe[...] then print("You're not RbxDev yet..") end
Report Abuse
Randy_Moss is not online. Randy_Moss
Joined: 05 Aug 2009
Total Posts: 30511
05 Jun 2016 03:17 PM
Oh, Alright thanks for this, it's working 100%.

I got one more question though, lets say the person leaves and they got there cards randomly generated, is it possible to save those cards that they have (for instance save the ID's they got randomly)
Report Abuse
xThe_Developer is not online. xThe_Developer
Joined: 07 Aug 2013
Total Posts: 585
05 Jun 2016 03:18 PM
You'd want to save it to a datastore, or do it the nooby way. With SaveNumber, etc. And then you could make it check if they have the card unless you want them to be able to get the same card over and over.


#code mod = require(sike) if not mod.xThe[...] then print("You're not RbxDev yet..") end
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