You really should put your code in a code block and tab it correctly, as it makes it much easier to read. Since this is so short, however, I can still be of help.
CFrame, in Roblox, ignores other bricks. Therefore you can use CFrame.Angles to rotate a brick while ignoring other bricks.
You should also add a debounce to help prevent glitching. A debounce is just a variable that prevents the code from running a second time until it's already finished running the first time. This is very useful for Touched events, because the way they work they may fire a bunch of times if the person remains standing on the brick.
Also the first few lines outside the function are kind of unnecessary, as you can just make those edits in studio.
local part = script.Parent
local debounce = false
function onTouched()
if not debounce then
debounce = true
part.CFrame = CFrame.Angles(0,math.rad( 89.98), 0)
wait(2)
part.CFrame = CFrame.Angles(0, 0, 0)
debounce = false
end
end
1 comment
Remember to accept the answer if it helped you and both you and Perci will get points