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: y u no

Previous Thread :: Next Thread 
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 04:08 PM
I can't seem to figure out why the script isn't detecting when the health value changes. inb4tl;dr

    script.Parent.Adornee = script.Parent.Parent
    local lastHealth = 100
    local lastHealth2 = 100
    local maxWidth = 0.96
    local curHealth = script.Parent.Parent.Parent.Parent.Health
    local maxHealth = script.Parent.Parent.Parent.Parent.MaxHealth
    local tray = script.Parent
    
    function UpdateGUI(health)
        local width = (health / maxHealth.Value) * maxWidth
        local height = 0.83
        local lastX = tray.bar.Position.X.Scale
        local x = 0.019 + (maxWidth - width)
        local y = 0.1
        
        tray.bar.Position = UDim2.new(x,0,y, 0)
        tray.bar.Size = UDim2.new(width, 0, height, 0)
        -- If more than 1/4 health, bar = green. Else, bar = red.
        if( (health / maxHealth.Value) ​> 0.25 ) then
            tray.barRed.Size = UDim2.new(0, 0, 0, 0)
        else
            tray.barRed.Position = tray.bar.Position
            tray.barRed.Size = tray.bar.Size
            tray.bar.Size = UDim2.new(0, 0, 0, 0)
        end
        
        lastHealth = health
    end
    
    
    function HealthChanged(change)
        print("Change!")
        health=change.Value
        UpdateGUI(health)
    end
    
    curHealth.Changed:connect(HealthChanged)
    curHealth.Value = 99


----------

Right. This is supposed to update a GUI to show the health value, I pretty much stole all this from the HealthScript 3.x from inside the character. Unfortunatly, it *won't update*. At all, I can't figure out why. I get no errors, and when I change the health value it doesn't print Change! like expected. It also doesn't even update even though the script *clearly* changes the value.

All help is appreciated. Thanks!
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
05 Apr 2012 04:32 PM
Floats don't have a changed event.
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
05 Apr 2012 04:33 PM
Oh wait it's a value not a humanoid? Let me look over it again
Report Abuse
trappingnoobs is not online. trappingnoobs
Joined: 05 Oct 2008
Total Posts: 19100
05 Apr 2012 04:34 PM

health=change.Value

Pretty sure that should be health=change since the argument sent when Changed is called on a Value is generally the new Value, not the object.
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 04:38 PM
Ffffffff-

I'll try again ;D Cheers
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 04:39 PM
I changed it, I ran it and it still doesn't detect any changes... no errors nothing the script is defiantly enabled because it changes the value to 99 at the end of the script.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
05 Apr 2012 04:58 PM
Properties don't have events:

"curHealth.Changed"
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:04 PM
It's a intValue?

Effectively it should be

    script.Parent.Pa~nt.Health.Changed
                        ^This is the intValue
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:08 PM
Ugh, if you're not using the forum enhancer its:

script.Parent.Pa~nt.Health.Changed
^This is the intValue
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:08 PM
I hate these forums ;_; Health is an intValue that's what I'm trying to say.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
05 Apr 2012 05:13 PM
Oh.

Well the function isn't gonna fire unless if you have some other script or explicitly change the IntValue.

Why not just use the .HealthChanged event of the Humanoid?
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
05 Apr 2012 05:14 PM
Never mind that. Maybe there is the Humanoid is healing? Try setting that value to 50?
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:19 PM
There isn't a humanoid in the model, I'm just using the health script to "Emulate" a humanoid. It's for health on a building, where you can destroy opponent buildings and stuff.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
05 Apr 2012 05:20 PM
When you said "no output", did that also imply that the function connected to .Changed didn't run?
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:24 PM
Yep. Because the function it connects to has print("Changed!")

When I change the value of Health, nothing appears in the output so it doesn't look like it is connected right.
But I'm not getting any errors or warnings at all.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
05 Apr 2012 05:28 PM
Weird.. I'm testing st00f out right now and this works:

script.Parent.Changed:connect(function(var)
print(var)
end)

script.Parent.Value = 5
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
05 Apr 2012 05:30 PM
Try scrolling up in the output, as the function will execute before some of the ROBLOX scripts that print random stuff.
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:39 PM
http://www.roblox.com/Oil-rig-thingie-item?id=76662217

This is the model, I've checked output and it's the same old st00f. /dissapoint
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:42 PM
Okay nevermind, it's randomly started working. I didn't change anything and it works ​>:/
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:44 PM
Actually, it only works when I play solo, it doesn't work when I test in studio.

By the way, thanks for the replies everyone, highly appreciated. ^_^
Report Abuse
Sonicthehedgehog9000 is not online. Sonicthehedgehog9000
Joined: 19 Jun 2009
Total Posts: 11932
05 Apr 2012 05:46 PM
DAT ID.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
05 Apr 2012 05:54 PM
Try adding a wait(0.5) at the beginning of the script.
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 05:59 PM
I put wait(5) to be safe, and print("Loaded!") so I know it's loading.

Studio: Press play, output displays Loaded! only and health is 99
Solo: Output displays Loaded! and Changed! and health is 99.

Freaky.
Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
05 Apr 2012 06:00 PM
OMG Sonic I just noticed o.o 666 ftw!
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
05 Apr 2012 06:00 PM
are u using a localscrept?
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