Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

8 comments

0

I'm confused, is this script located on the client or the server?

0

client

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.

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

0

enabled.

0

Are all the element scripts the same?

0

Almost

0

The only thing that changes is the thing they set off

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.