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: This works, but it breaks every-so-often...why?

Previous Thread :: Next Thread 
devTools is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
29 Oct 2014 10:26 PM
It works for like 5 mins of constant use, but then it breaks so that it wont change your decal. I have a long list of items and decal IDs in a table that all work, but this is the script without the table:

function changeDecal()
rand = math.random(1,50) -- Change to the number of Items in the table
game.Workspace.Background.Decal.Texture = Items[rand][2]
end

game.Players.PlayerAdded:connect(function(plr)
plr:WaitForChild("leaderstats")
plr.leaderstats:WaitForChild("Points")
plr.leaderstats:WaitForChild("Wins")

changeDecal()

while wait() do
wait(1)

plr.Chatted:connect(function(msg)
if msg:lower() == Items[rand][1] then
plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 50
plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value + 1
wait(1)
changeDecal()
end
end)
end
end)

Help?


| devTools || Builder | Forumer | Beginning Scripter | Add 1.5k Posts |
Report Abuse
devTools is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
29 Oct 2014 10:31 PM
b1

| devTools || Builder | Forumer | Beginning Scripter | Add 1.5k Posts |
Report Abuse
devTools is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
29 Oct 2014 10:50 PM
b2


| devTools || Builder | Forumer | Beginning Scripter | Add 1.5k Posts |
Report Abuse
devTools is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
29 Oct 2014 10:58 PM
b3


| devTools || Builder | Forumer | Beginning Scripter | Add 1.5k Posts |
Report Abuse
nacker is not online. nacker
Joined: 06 Oct 2009
Total Posts: 6034
29 Oct 2014 11:52 PM
would help if you could include the table
Report Abuse
devTools is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
30 Oct 2014 12:16 AM
Its 50 tables inside a table like this:

Items = {
{"evil skeptic","http://www.roblox.com/asset/?id=77727836"},
{"hyperlaser","http://www.roblox.com/asset/?id=180538479"}}


| devTools || Builder | Forumer | Beginning Scripter | Add 1.5k Posts |
Report Abuse
devTools is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
30 Oct 2014 12:42 AM
Help?


| devTools || Builder | Forumer | Beginning Scripter | Add 1.5k Posts |
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
30 Oct 2014 12:54 AM
I don't understand how a script can only work sometimes. A script usually works all the time or never works in the first place.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
30 Oct 2014 01:04 AM
@lego not necessarily. a lot of beginners tend to make glitchy scripts which break easily
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
30 Oct 2014 01:13 AM
Ah I see, there is a math.random at the beginning. Maybe it's outputting numbers that the script doesn't know what to do with so then it errors?
Report Abuse
devTools is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
30 Oct 2014 06:43 AM
But I set parameters for the random.
Report Abuse
FireDesign is not online. FireDesign
Joined: 22 Feb 2012
Total Posts: 104
30 Oct 2014 07:09 AM
you can do this so much easier, but I don't fix over-complicated scripts.



mom, i created admin, are you proud?
Report Abuse
FireDesign is not online. FireDesign
Joined: 22 Feb 2012
Total Posts: 104
30 Oct 2014 07:10 AM
It's doing it because it's choosing numbers like 1.2393842, not just Integers.



mom, i created admin, are you proud?
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
30 Oct 2014 07:13 AM
@FireDesign umm
http://wiki.roblox.com/index.php?title=Function_dump/Mathematical_functions#math.random

"math.random ([m [, n]])

This function returns a random integer between m and n"

~The herp lerped a derp~
Report Abuse
devTools is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
30 Oct 2014 07:14 AM
How do I make it only choose whole numbers?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
30 Oct 2014 07:21 AM
Fire was being stupid; it already returns only whole numbers.
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