My door script doesnt work

local ClickDetector = script.Parent.ClickDetector

local Door = script.Parent.Parent.Door

local TweenService = game:GetService(“TweenService”)

local Info = TweenInfo.new(

2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
true,
0

)

local Goal =
{
Position = Vector3.new(Door.Position.X +0, Door.Position.Y -6, Door.Position.Z +0)
}

local MoveDoor = TweenService:Create(Door, Info, Goal)

ClickDetector.MouseClick:Connect(function()

MoveDoor.play(MoveDoor)

end)

I cant figure out where the flaw is please help!

It’s actually:

MoveDoor:Play()

Don’t include anything in the brackets.

I have tried this before and it doesnt seem to be a solution.

Are there any errors in your output?

Couldn’t understand your script since it wasn’t formatted properly, so here’s a cleaner version:

local TweenService = game:GetService(“TweenService”)

local ClickDetector = script.Parent.ClickDetector
local Door = script.Parent.Parent.Door

local Info = TweenInfo.new(
    2,
    Enum.EasingStyle.Sine,
    Enum.EasingDirection.Out,
    0,
    true,
    0
)

local Goal = {
    Position = Vector3.new(Door.Position.X +0, Door.Position.Y -6, Door.Position.Z +0)
}

local MoveDoor = TweenService:Create(Door, Info, Goal)

ClickDetector.MouseClick:Connect(function()
    MoveDoor.play(MoveDoor)
end)

So, first of all. It’s not MoveDoor.play(MoveDoor)
Should be MoveDoor:Play()

Again, you did mention it didn’t work. Then try adding a print on the MouseClick event?

ClickDetector.MouseClick:Connect(function()
    print("Playing tween..")
    MoveDoor:Play()
end)

Then next, are you sure the Door variable is a part?

Right now it is grouped, will that affect it?

Could you show your explorer to make it clearer?

That explains it. You messed up your Ancestor placement.

It should be

local Door = script.Parent.Parent.Parent.Parent.Door

And for the door tweening, not going to do all the stuff. Here’s a video on it.

If there’s still any problems then let me know!

Oh my god I didn’t even notice, I guess I didn’t think much about adding it so far down there.

1 Like

Here’s more of a shorter version:

local Door = script:FindFirstAncestor("BlastDoor").Door
1 Like

It isn’t printing the print(“Playing tween…”) when I click.

Weird

Try printing ClickDetector.Name instead?

That’s the script so far for reference.

Have you checked the output on what’s printing or not?

And also it’s :Play() not :play()

They “Play” didn’t fix the problem and it isn’t outputting anything since I started today.

Mind sending a picture of the output, after clicking?

Yeah, Position isn’t a valid property of a Model. Watch the video I sent. It’ll fix your problem.

1 Like