Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Yeevivor4 155
10 years ago
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

Log in to vote
1
Answered by
Damo999 182
10 years ago

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)
Ad
Log in to vote
0
Answered by
Trewier 146
10 years ago

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.

Answer this question