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

Help on my GUI property change script?

Asked by
Mystdar 352 Moderation Voter
10 years ago

Basically is it meant to make the transparency of a frame, dependent on a player's IntValue. The local script is here The

The code in the script:

-- This is a local script
local player = game.Players.LocalPlayer -- The local player
local sword = player.Folder:WaitForChild("PWSword") -- Wait for this to go into the Player (from another script) 
--Folder is the model containing it
local frame = script.Parent -- The Frame 
-- Gap
if sword.Value>0 then -- If the sword's value is above 0 then
    frame.Transparency = 1 -- make this frame invisible
elseif sword.Value == 0 then -- Otherwise if it is 0
    frame.Transparency = 0.2 -- Make it almost Opaque
end -- ends that
-- Gap
sword.Changed:connect(function() -- When the sword's value changes
    if sword.Value>0 then -- if it is above above 0 then
        frame.Transparency = 1 -- make this frame invisible
    elseif sword.Value == 0 then  -- Otherwise if it is 0
        frame.Transparency = 0.2 -- Make it almost Opaque
    end -- endy endy
end) -- ending my function

READ: The problem is, when I clone it in the player's GUI (with another script) it is normal (without changes to what I set it's base properties as, so wrong if it was above 0), however if I remove it, then put it back in the PlayerGUI (in studio) then it works. Then if I change the value (to 0) nothing happens it just stays at the previous transparency, but if I drag it out and in, it goes dark again, help?

1 answer

Log in to vote
0
Answered by 10 years ago

Your problem is that you capitalized the C in :connect. Lua is case-sensitive.

0
I'll check that out Mystdar 352 — 10y
0
I'm afraid that still hasn;t fixed my previous problem, the script still only works when it has been dragged out then in, even when changed. Mystdar 352 — 10y
0
Hm. Well, if that isn't the problem, then your problem is most likely something with the timing on things loading in, perhaps you have attempted to access the Gui before it has loaded, etc. It makes no sense when you look at the script, but I've had a lot of experience and frustrations with things not loading. I suggest just adding a wait(2) at the beginning to give you time. Inefficient, but it's SlickPwner 534 — 10y
Ad

Answer this question