|
| 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 |
|
|
| |
|
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 |
|
|
| |
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|