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

Trouble with causing something to happen when value changes? [SOLVED]

Asked by 5 years ago
Edited 5 years ago

So, I'm trying to make it so that when the value of this IntValue changes, a script becomes enabled. When the value changes, the script is still disabled. I can't seem to figure out the problem and want to see if anyone can find a solution. (lstats is leaderstats, but I just changed the name)

game.Players.PlayerAdded:Connect(function(player)
    repeat wait() until player.Character

    local element = script.Parent.Parent.lstats.Element

element.Changed:Connect(function()
    if element.Value == 1 then
        player.PlayerGui.Element.Disabled = false
    end
    if element.Value == 2 then
        player.PlayerGui.Element2.Disabled = false
    end
    if element.Value == 3 then
        player.PlayerGui.Element3.Disabled = false
    end
    if element.Value == 4 then
        player.PlayerGui.Element4.Disabled = false
    end
    if element.Value == 5 then
        player.PlayerGui.Element5.Disabled = false
    end
    if element.Value == 6 then
        player.PlayerGui.Element6.Disabled = false
    end
end)

0
I'm confused, is this script located on the client or the server? User#9949 0 — 5y
0
client Conquesias 85 — 5y
0
Can you explain what each script does and the difference between them (or if they are the same), and also what exactly this is for. mattscy 3725 — 5y
0
I don't quite understand what you mean by the first part of your question, but the script here is meant to take the Value from the IntValue called "Element". I made another script to of course make the IntValue and the Value of it is from 1-6. If the value equals one of those numbers, a certain script gets enabled. Example: If it equals 1, the script titled Element1 which is in PlayerGui gets Conquesias 85 — 5y
View all comments (4 more)
0
enabled. Conquesias 85 — 5y
0
Are all the element scripts the same? mattscy 3725 — 5y
0
Almost Conquesias 85 — 5y
0
The only thing that changes is the thing they set off Conquesias 85 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I fixed the issue myself. I first changed this over to a server script and then there was also an issue with my other script that made the value. It set it automatically as a number 1 through 6, but I was using the Changed event. To fix this, in my other script, I put a wait(1) and then changed the value. (the wait isn't necessary though.)

Ad

Answer this question