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

Platform not changing CFrame? [Unanswered]

I used the script that was my answer, but didn't solve my problem

local platform = workspace.Platform
local stop1, stop2 = workspace.Stop1 or workspace.Stop2
stop1.Touched:connect(function(hit)
    if hit==platform then
        print("Stop1 touched the platform")
       hit.CFrame = platform.CFrame * CFrame.new(0,0,.1)
end
end)
stop2.Touched:connect(function(hit)
 if hit==platform then
        print("Stop1 touched the platform")
       hit.CFrame = platform.CFrame * CFrame.new(0,0,-.1)
end
end)

The problem is that it won't move

1 comment

0

Touched doesn't fire if you change it's CFrame and goes to a part.

1 answer

"onTouched" is not a built in function. And if it was, you still didn't call it in your code. You also don't need a loop, and you can't add a Vector3 to a CFrame. Try studying this code:

local platform = workspace.Platform
local stop1, stop2 = workspace.Stop1, workspace.Stop2

platform.Touched:connect(function(hit)
	if hit==stop1 then
		print("Stop1 touched the platform")
		hit.CFrame = platform.CFrame * CFrame.new(0,0,10)
	elseif hit==stop2 then
		print("Stop2 touched the platform")
		hit.CFrame = platform.CFrame * CFrame.new(0,0,-10)
	end
end)

3 comments

0

What about it moving towards the part?

0

You want the part that touches the platform to move more toward the platform?

0

I want the platform to move towards the stop1 and moves back towards the stop2

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