There’s an easier way to do functions instead of writing them and calling them, however in some cases this method is not preferred over calling it separately. But, for now this is a faster method for calling a function once the Touched event occurs.
On Line 1, we are defining the variable so it is easier than typing it out later in the script. We use local variables so it is only accessible in the function and nowhere else in the script. On Line 3 we are saying if the brick is touched, then this happens. On the next line, however, we say that this only happens if something with a humanoid in it touches it (Player). Then, we tell it to move 10 studs in the z direction. We wait one second, and then end the function.
local brick = workspace.partypartpart
brick.Touched:Connect(function(hit))
it hit.Parent:FindFirstChild(“Humanoid”) then
brick.CFrame = brick.CFrame + Vector3.new(0, 0, 10)
wait(1)
end
end
2 comments
You are not connecting onTouch to an event, nor did you use enough ends.
You’re not calling the function and there isn’t enough ends for your conditional statements