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

Touched Event Wont Work or Print in Output, how do i fix this?

So Im making a button press game, where you press a button at a spacific time by touching a part. I used the script, everything worked but the touched event, I even used print and it didnt show up in output. Can someone please help?

local t = 0
local restart = false
local timer = game:GetService("ReplicatedStorage"):FindFirstChild("Timer")
while true do
	while true do
		if t == 0 then
			for t0 = 5,0,-1 do
				wait(1)

				timer.Value = "Intermission: "..t0
				if t0== 0 then
					t = 1
				end


			end



		elseif t == 1 then
			game.Workspace.Wall.Transparency = 1
			game.Workspace.Wall.CanCollide = false
			for t1 = 5,0,-1 do
				wait(1)
				timer.Value = "Time untill press: "..t1
				if t1== 0 then
					t = 2
				end
			end



		elseif t == 2 then
			for t2 = 5,0,-1 do
				wait(1)
				timer.Value = "Time to press button: "..t2

			end



		elseif t == 3 then
			for t3 = 55,0,-1 do
				wait(1)
				timer.Value = "Time untill press: "..t3
				if t3== 0 then
					t = 4
				end
			end



		elseif t == 4 then
			for t4 = 5,0,-1 do
				wait(1)
				timer.Value = "Time to press button: "..t4

			end


		elseif t == 5 then
			for t5 = 55,0,-1 do
				wait(1)
				timer.Value = "Time untill press: "..t5
				if t5== 0 then
					t = 6
				end
			end

		elseif t == 6 then
			for t6 = 5,0,-1 do
				wait(1)
				timer.Value = "Time to press button: "..t6

			end
		end
		if t == 10 then
			print(t)
			break

		end	

	end
end

function GAME()

	print("a")
	if t == 2 then
		t = 3

	elseif t == 4 then
		t = 5

	elseif t == 6 then
		t = 7

	elseif t == 1 then
		t = 10

	elseif t == 3 then
		t = 10

	elseif t == 5 then
		t = 10

		end
		end

script.Parent.Touched:Connect(GAME)

Edit: By JesseSong:

Ensure you've encoded your code in a code block properly in the future so it makes it easier to read. It also makes it likely that your question will get solved by the community. If you need any further assistance please click on the hyperlink here! it has a full documentary on error-fixing, code blocks and so on!

Thanks, JesseSong

1 comment

0

Can you organize your code, it's so hard to read like this

1 answer

Nevermind, I put the touched event in the loop and it works.

2 comments

0

Also, make your Game function a local function.

0

local function Game(), if you are just using it for Touched event only.

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