Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Lets say i have 2 surface GUIS....?

Asked by 6 years ago

I have 2 surface GUIS, And when I aim a gun I want it to be so one appears and one disappears, Let's say the one for when I aim is b will appear and A will disappear, and if I'm not aiming, A will appear and B will disappear,

So i made this script,

if Aiming = false 
    WaitForChild("RHUD")
    WaitForChild("Ammo)
        RHUD.Ammo.properties.TextTransparency = 1
    )

end
if Aiming = true 
    WaitForChild("HUD")
    WaitForChild("Frame")
        HUD.Frame.properties.Visible = false
    )

I might have it all wrong, Im pretty new to LUA, Help is apreachated!

Thanks! James Bread armyofdeath909 “Two possibilities exist: either we are alone in the Universe or we are not. Both are equally terrifying.”

? Arthur C. Clarke

0
Please spell it as Lua, not LUA. http://acronyms.thefreedictionary.com/lua hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago
Edited 6 years ago

Make the 'Aiming' variable a BoolValue. Instead of changing the variable, manipulate the BoolValue's Value property.

You should do this because all ValueObjects have the Changed event. The Changed even fires whenever the specified object's value is changed. You can use this to do what you want.

local A; --Your first SurfaceGui's Frame
local B; --Your second SurfaceGui's Frame
local aim = script.Parent; --The value that will change

aim.Changed:Connect(function(result)
    A.Visible = not result;
    B.Visible = result;
end)
--result: true
--A: false
--B: true

--To change aim from another script:
--script.Parent.Aim.Value = true;
1
Thanks! Its worked flawlessly! armyofdeath909 -6 — 6y
0
No problem ;D Goulstem 8144 — 6y
Ad

Answer this question