|
| 01 Mar 2014 08:46 PM |
local ads = { ['Ad here!'] = true; ['Advertizement here!'] = true; ['Another ad here!'] = true }
while wait() do local currentad = ads[math.random(1, #ads)] script.Parent.TextLabel.Text = currentad script.Parent:TweenSize(1, 0, 1, 0, "out", "Quad", 2 , true) wait(5) script.Parent:TweenSize(0, 0, 0, 0, "out", "Quad", 2 , true) end
--[[Got this error... 21:38:28.277 - Workspace.Part.SurfaceGui.Frame.Script:7: bad argument #2 to 'random' (interval is empty) --]] |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Mar 2014 09:15 PM |
| b2 I know someone out there knows how to fix this.. Please help... |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:17 PM |
#ads is 0. The length operator doesn't count dictionary entries. You could modify its metatable to do this, though.
setmetatable(ads, {__len = function(t) local i = 0 for _, v in pairs(t) do i = i + 1 end return i end})
Put that under the definition of your ads table. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:21 PM |
| local ads = {['Ad here!'],['Advertizement here!'],['Another ad here!']} |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:23 PM |
Woops. You implementation would require the above post, not mine.
Sorry! |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:23 PM |
local ads = { ['Ad here!'] = 1; ['Advertizement here!'] = 2; ['Another ad here!'] = 3 }
while wait() do local currentad = ads[math.random(1, #ads)] script.Parent.TextLabel.Text = currentad script.Parent:TweenSize(1, 0, 1, 0, "out", "Quad", 2 , true) wait(5) script.Parent:TweenSize(0, 0, 0, 0, "out", "Quad", 2 , true) end
Agent would this also work? |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:32 PM |
you don't need to index them as 1,2,3 they are indexed themselves like I said: local ads = {'Ad here!','Advertizement here!','Another ad here!'} |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:44 PM |
| Island I tried that I got the error that I needed a '=' after ','.. I tried putting a = after comma and I got the origional error. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:46 PM |
ads = {"ad here!","ad number 2!","yello!ima ad:3"} currentad = ads[math.random(1,#ads)] print (currentad) ur doing something rong,this works |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:48 PM |
| @Island I tried the new one now it changes the text to a number... |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 09:50 PM |
you are really messin up here.. post your current script |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Mar 2014 10:07 PM |
Now I'm getting this error:
Unable to cast double to UDim2 - Line 7
ads = {"ad here!","ad number 2!","yello!ima ad:3"}
while wait() do local currentad = ads[math.random(1, #ads)] script.Parent.TextLabel.Text = currentad print(currentad) script.Parent:TweenSize(1, 0, 1, 0, Out, Quad, 1, true) wait(5) script.Parent:TweenSize(0, 0, 0, 0, Out, Quad, 1, true) end |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Mar 2014 10:09 PM |
| First argument of TweenSize is a UDim2 value. You put numbers. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 10:13 PM |
>line 7 You're line 7 says :TweenSize(1, 0, 1, 0, Out, Quad, 1, true)). How's it suppose to move if Gui's Sizes/Positions work with UDim2.new()? Just simply add the following to line 7 and line 9: Line7:script.Parent:TweenSize(UDim2.new(1, 0, 1, 0), 'Out', 'Quad', 1, true) Line9:script.Parent:TweenSize(UDim2.new(0, 0, 0, 0), 'Out', 'Quad', 1, true) |
|
|
| Report Abuse |
|
|