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: Problem with localscripts

Previous Thread :: Next Thread 
litozinnamon is online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
25 Jan 2012 11:45 PM
Now the function itself runs fine, there is nothing wrong with it, however, sometimes the localscript does not even change the values properly but it thinks it has.

Problem: The normal scripts in the tool will register the ammo value as 0. In roblox studio explorer when you click the ammo object and look up its properties, it will also read 0. However the localscripts will somehow read it as 30, major conflict that roblox needs to fix

Any solutions?
______________________________
AmmoLostOnReload= 30
reloading = false

function Reload()

if reloading then return end

if Tool.AmmoScript.Ammo.Value == AmmoLostOnReload then return end

if Tool.AmmoScript.Clip.Value > 0 then

if not Tool.Parent:findFirstChild("Humanoid") then return end

AmmoLeft = Tool.AmmoScript.Ammo.Value
TotalAmmo = Tool.AmmoScript.Clip.Value

if Tool.AmmoScript.Clip.Value >= AmmoLostOnReload then

wait()

Tool.AmmoScript.Ammo.Value = AmmoLostOnReload
Tool.AmmoScript.Clip.Value = Tool.AmmoScript.Clip.Value - AmmoLostOnReload + AmmoLeft
reloading = false

elseif Tool.AmmoScript.Clip.Value < AmmoLostOnReload then

if TotalAmmo + AmmoLeft >= AmmoLostOnReload then

Tool.AmmoScript.Ammo.Value = AmmoLostOnReload
Tool.AmmoScript.Clip.Value = Tool.AmmoScript.Clip.Value - AmmoLostOnReload + AmmoLeft

elseif TotalAmmo + AmmoLeft < AmmoLostOnReload then

Tool.AmmoScript.Ammo.Value = TotalAmmo + AmmoLeft
Tool.AmmoScript.Clip.Value = 0

end
reloading = false

end

end

end
Report Abuse
litozinnamon is online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
26 Jan 2012 12:45 AM
bump
Report Abuse
BenBonez is not online. BenBonez
Joined: 29 Aug 2008
Total Posts: 19362
26 Jan 2012 02:41 AM
"AmmoLeft = Tool.AmmoScript.Ammo.Value
TotalAmmo = Tool.AmmoScript.Clip.Value"

You are assign it the momentarily value but not the object itself.
Try pointing it at the object instead and then changing the objects value like this:

AmmoLeft = Tool.AmmoScript.Ammo
TotalAmmo = Tool.AmmoScript.Clip

.... if blah blah and AmmoLeft.Value==something then...
Report Abuse
litozinnamon is online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
26 Jan 2012 07:51 PM
hmm I'll try that then
Report Abuse
litozinnamon is online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
26 Jan 2012 07:54 PM
Nope still doesn't work
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
26 Jan 2012 08:01 PM
Where exactly is the script saying that the ammo is 30?
Report Abuse
litozinnamon is online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
26 Jan 2012 08:11 PM
That isn't the point, it's somewhere else in the script and the script works fine. What I'm saying is that there is a major contradiction in changing the values of an IntValue object between localscripts and scripts
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
26 Jan 2012 08:13 PM
It really does matter. Are you trying to change it from this script to 30 and it doesn't change or are you finding that somewhere else in the script the script thinks that it's 30?
Report Abuse
litozinnamon is online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
26 Jan 2012 08:54 PM
No, a localscript reads the value of intvalue differently than a normal script when an error occurs. It is just something robox needs to fix
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
26 Jan 2012 08:56 PM
If you would show me the line where this is, I could tell you what you did wrong...
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