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

How do I do this?

When I make my scripts they all seem to need me to disable then enable then in the explorer properties thing please help. Even if I do what I would consider a good code it still does it like this one I made.

local brick = game.Workspace.Brick

function onTouch(part)
brick.Transparency = 1
wait(1)
brick.Transparency = 0

end

brick.Touched:connect(onTouch)

2 answers

Changing the source of a script means absolutely nothing if its old code is already running. One solution if you don't want to disable and enable is to stop writing when the world is currently being simulated.

2 comments

0

What do you mean by the world is being simulated?

0

If the world is not being simulated then it is paused and no code is running. You think you're editing the code that is running, but you can't do that. The code is read and the read code is run. You're changing the code that gets read after it already has been read, so you have to tell it to read it again.

Why are you calling the variable "brick" inside your function when you have already an argument called "part" that passes your brick? Change this:

function onTouch(part)
	brick.Transparency = 1
	wait(1)
	brick.Transparency = 0
end

to this:

function onTouch(part)
	part.Transparency = 1
	wait(1)
	part.Transparency = 0
end

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