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

This script doesn't show its effect but its able to output prints?

It doesn't have any error output but when I put prints in it it appears in the output

Anywhere I put a print its able to print it out in the console/output but the rest of the code has no effect on the surface gui

Anything that I am doing wrong here?

Output

while true do
		corrupt = math.random(1, 8)
				if corrupt == 1 then
						script.Parent.Frame.corrupt.Text = "???????????????????????????????"
				end
				if corrupt == 2 then
						print("test")-- outputted in the console yet the other code doesnt show its effect
						script.Parent.Frame.corrupt.Text = "i wanna be ur friend"
				end
				if corrupt == 3 then
						script.Parent.Frame.corrupt.Text = "@#*$&(#@*$*(&@#($&@#*&$(@#*"
				end
				if corrupt == 4 then
						script.Parent.Frame.corrupt.Text = "3453439324032432423490823"
				end
				if corrupt == 5 then
						script.Parent.Frame.corrupt.Text = "u cant hide"
				end
				if corrupt == 6 then
						script.Parent.Frame.corrupt.Text = "666666666666666666666666"
				end
				if corrupt == 7 then
						script.Parent.Frame.corrupt.Text = "dRUAK"
						script.Parent.Frame.corrupt.corrupt2.Text = "erENEGEy"
						script.Parent.Frame.corrupt.TextColor3 = Color3.fromRGB(255, 85, 0)
						script.Parent.Frame.corrupt.TextStrokeColor3 = Color3.fromRGB(255, 170, 0)
						script.Parent.Frame.corrupt.corrupt2.Visible = true
						script.Parent.Frame.corrupt.Font = Enum.Font.Antique
				end
				if corrupt == 8 then
						script.Parent.Frame.corrupt.Text = "will kill u"
				end
				wait(math.random(0.1, 0.2))
end

2 comments

0

Can I ask where you learn how to code this way from? It looked like trashcan stuffed with code

0

I made it. Sometimes scripts I make don't work, cause I'm not really the best scripter.

2 answers

✓ Accepted answer

Since the print statement is printing out repeatedly, your script is very likely working. You can get more information by printing print(script.Parent.Frame.corrupt.Text) right before the wait command. You might also consider making sure that the object the script is modifying is the same one you're looking at in the 3D world -- you might try print(script.Parent.Frame.corrupt:GetFullName()), which will print the "path" to the object (starting with 'game').

You have a lot of repetition in your script; you might consider using tables like this:

local options = {
	{Text = "Option1"},
	{Text = "Option2"},
	{Text = "Option3", TextColor = Color3.fromRGB(255, 85, 0), Text2 = "2nd part"},
	--etc
}
local container = script.Parent.Frame
local option
local defaultColor = container.Corrupt.TextColor
while true do
	option = options[math.random(1, #options)]
	container.Corrupt.Text = option.Text or ""
	container.Corrupt.TextColor = option.TextColor or defaultColor
	container.Corrupt.Corrupt2.Text = option.Text2 or ""
	--etc
	wait(math.random(0.1, 0.2))
end

The option.Text or "" means that if you don't provide Text = in any of the options, it will use an empty string by default (and the same idea applies to the other properties).

As you can see, there isn't a series of if statements when using tables - only a series of entries in the options table. As a plus, if you change what Corrupt is named, or where Corrupt2 is located, you need only change it in one place. As a third benefit, this script always assigns a value to things like TextColor, ensuring that if one of the options changes it (like corrupt == 7 does in your original script), you don't need to worry about changing the text colour back.

I find that the variable "corrupt" is being used in two different ways.

corrupt = math.random(1, 8)
if corrupt == 1 then
script.Parent.Frame.corrupt.Text = "???????????????????????????????"
end

so corrupt is a variable that represents a random value or is it a value after the frame that controls something?

6 comments

0

if corrupt is the title, then rename it to something else

0

corrupt is the text name and the variable

0

changing name does nothing tho.

0

is it in a script

0

"script.Parent.Frame.corrupt" just means "get the parent of the script, then get its child named 'Frame', then get the Frame's child named 'corrupt'", and so has nothing to do with the local variable 'corrupt'.

0

are you using a surface gui?

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