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

How come this local script wont start?(Filtering Enabled)

So I have a script that when its text hits zero it has a pull like part in it that if it is 1 the text changes and if it's 2 it's denied and its a 50% 50%, but the randomizer seems not to start at all, and I have no idea why it won't work is it, because of another script I have?

---Problem Script---

local num = math.random(1,2)

if script.Parent.Text == "0" then
	wait(1)
	if num == 1 then
		script.Parent.Text = "Hired"
	elseif
		num == 2 then
			script.Parent.Text = "Denied"
	end
end

---Problem Script(With a Print)

local num = math.random(1,2)

print "script.Parent.Text"

if script.Parent.Text == "0" then
	wait(1)
	if num == 1 then
		script.Parent.Text = "Hired"
	elseif
		num == 2 then
			script.Parent.Text = "Denied"
	end
end

---Good Script---

local seconds = script.Parent.Parent.Parent.Parent.Parent.Frame2.Time

if script.Parent.Text == seconds.Value then
	
	script.Parent.Text = seconds.Value
	
	for i = 1,seconds.Value do
		wait(1)
		seconds.Value = seconds.Value - 1
		script.Parent.Text = seconds.Value
	end
end

2 comments

0

Why is the seconds variable defined below the if then check using it? [local seconds = script.Parent.Parent.Parent.Parent.Parent.Frame2.Time]

0

I have just fixxed it.

1 answer

✓ Accepted answer

Your script was only running when the game started. You need a function to see when the text changes and then see if the text is zero.

local num = math.random(1,2)

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	if script.Parent.Text == "0" then
		if num == 1 then
			script.Parent.Text = "Hired"
		elseif
			num == 2 then
				script.Parent.Text = "Denied"
		end
	end
end)

2 comments

0

Almost 2000 :O

0

yeah ik excited about it

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