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

Moving Door Script. Not Working Properly. Any help? [Script Edited]

This script here is suppose to [On clicked] move like a regular door would to open. Not making one part transparent and the other not. Like a realistic door movement. If you have ever played Vampire Hunters 2, it is suppose to be similar to those doors. However it isn't working. Im attempting to use SetPrimaryPart but im not sure if it is done correctly.

Script:

script.Parent.PrimaryPart = script.Parent.Main
local Main = script.Parent:SetPrimaryPartCFrame(CFrame.new(61.99, 4.04, 8.81))

function onClicked()
	if script.Parent.Open.Value == 1 then 
		for i = 0,1.5,0.1 do 
			wait(0.1)
			Main.CFrame = Main.CFrame*CFrame.fromEulerAnglesXYZ(0,-0.1,0)*CFrame.new(0.01,0,-0.25)
		end
			Main.CFrame = Main*CFrame.fromEulerAnglesXYZ(0,-math.pi/2,0)*CFrame.new(-2.5,0,-2.5)
			script.Parent.Open.Value = 0
		end
if script.Parent.Open.Value == 0 then
	for i = 0,1.5,0.1 do
		wait(0.1)
		Main.CFrame = Main.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)*CFrame.new(-0.01,0,0.25)
	end
		Main.CFrame = Main*CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)*CFrame.new(-2.5,0,2.5)
		script.Parent.Open.Value = 1
	end
end
									
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

I tried setting this up, similar to you, maybe check console? Because when I do it, I get PrimaryPart is not a valid member of Part. Maybe try checking console and see if there's any errors. I hope this helped. :)

2 comments

0

But also, I don't know how you set this up, so maybe it's just me, but check to see. :)

0

i posted another question, I got further in the script but however it breaks at a certain point

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