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

How to make a brick move forward when you touch it?

FF = script.Parent

function onTouched(hit)
	local human = hit.Parent:findFirstChild("Humanoid")
	if (human ~= nil) then
		for loop = 1, 100 do
	FF.CFrame = FF. CFrame *CFrame Position(0, 50, 0)
	wait(1/25)
		
		end
	end
	script.Parent.Touched:connect(onTouched)

I don't know how to do it. The Overview says that Touched is not a valid member of workspace. I just don't understand.

2 answers

✓ Accepted answer

In your script you put this FF.CFrame = FF. CFrame *CFrame Position(0, 50, 0) you need to put CFrame.new not CFrame Position and even if you did add CFrame Position it would CFrame.Position and you also forgot an end. To make the brick move forward you must use the z axiz (X,Y,Z) the x axis move the brick left and right the y axis moves the part up and the z axis moves the brick back and forwards.

FF = script.Parent

function onTouched(hit)
    local human = hit.Parent:findFirstChild("Humanoid")
    if (human ~= nil) then
        for loop = 1, 100 do
    FF.CFrame = FF. CFrame *CFrame.new(0, 0, 50) --z axis moves it forward.
    wait(1/25)

        end
    end
end
    script.Parent.Touched:connect(onTouched)

The only thing that I could think of that could be affecting this is that the script should be inside the brick. Otherwise it looks perfectly fine.

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