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 make a block move once a message appears on the screen?

So in the lobby of my game there's an elevator. I want it to move once the timer reaches 1. So far its not working.

local model = game.Workspace.MovingPlatformModel
local platform = model.Platform
local start = model.Start
local finish = model.Finish
local body = platform.BodyPosition


	if script.MessageService.Value == "1" then
	body.position = finish.Position 
	wait(20)
	body.position = start.Position
	wait(20)
end

They're 3 blocks to the elevator a start block, the elevator its self, and a finish block.

1 answer

The if statement isn't going to wait for your value to be changed.. it's just going to be read at the start of the server, and be done.

Use the Changed event so your code fires when the object's Position property changes.

local model = workspace.MovingPlatformModel
local platform = model.Platform
local start = model.Start
local finish = model.Finish
local body = platform.BodyPosition

script.MessageService.Changed:Connect(function(c)
	if c == "1" then
		body.Position = finish.Position 
		wait(20)
		body.Position = start.Position
		wait(20)
	end
end)

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