SmakToj
(SmakToj)
February 13, 2023, 7:55pm
#1
Hello!
I am currently trying to script an animated door. When you click on the door handle, the door opens and then a few seconds later it should close.
However it does not seem to be working.
(The weld constraints connect to the primary part)
This is the script in the door model:
local door = script.Parent.Parent
local doorHinge = door.PrimaryPart
local doorOpen = TweenInfo.new()
local doorCFrame = TweenService:Create(doorHinge, doorOpen, {
CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(-100),0)
})
local doorCFrameClosed = TweenService:Create(doorHinge, doorOpen, {
CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(0),0)
})
local ClickDetector = script.Parent.Parent.Handle.ClickDetector
ClickDetector.MouseClick:Connect(function()
doorCFrame:Play()
script.Parent.Open:Play()
wait(3)
doorCFrameClosed:Play()
wait(1)
script.Parent.Close:Play()
end)
I don’t know what the issue is but if anyone could help me out it would be heavily appreciated.
Scottifly
(Scottifly)
February 13, 2023, 8:14pm
#2
I don’t see an icon change when you mouse over the Handle. Put a Print(“Handle clicked”) inside the ClickDetector section of the script.
Is your hinge Part Anchored, and are the rest of the Parts Unanchored and welded to the HingePart?
jXD20072
(jXD20072)
February 13, 2023, 8:32pm
#3
Is the primaryPart moving? WeldConstraints only work for parts moved by physics objects like alignOrientation or alignPosition, but not tweens if I recall correctly.
Scottifly
(Scottifly)
February 13, 2023, 8:35pm
#4
Parts that move with Anchored Tweened parts need to be welded to them.
Yeah or they don’t move with it.
I think your suspicion about the click detector being faulty is most likely correct.
Try using an invisible part around the handle and connecting the click detector to that instead? It may be that the handle mesh’s click detection region is too small?
jXD20072
(jXD20072)
February 13, 2023, 8:40pm
#6
A WeldConstraint won’t move parts connected if one of them is moved by a tween i think. The script has to be fine because the sound is playing correctly…
If you have done every step correctly, if will still work, Here is a little guide to help u. Introduction to Tweening Models - Resources / Community Tutorials - DevForum | Roblox
1 Like
Scottifly
(Scottifly)
February 13, 2023, 10:40pm
#8
I tried a transparent Part years ago with a Decal on it years ago and it wouldn’t register the ClickDetector.
Dunno if they have changed that though.
@jxd as explained in the link that @BobbieTrooper posted, WeldConstraints are what hold Unanchored Parts to Anchored Parts that are tweened.
@SmakToj you can use a welded Motor
jXD20072
(jXD20072)
February 13, 2023, 10:52pm
#9
That’s strange… WeldConstraints don’t move both of the parts connected if only one is being affected by a tween, I just checked. Is the part you are trying to tween rotating, though?
SmakToj
(SmakToj)
February 17, 2023, 9:16pm
#10
Yeah I don’t think it’s registering the click.
Like I suggested earlier, try putting an invisible part around the door handle and connecting the click detector to that
Scottifly
(Scottifly)
February 25, 2023, 8:31pm
#12
Does the mouse icon change when you hover over the Part that has the ClickDetector in it?
apictrain0
(apictrain0)
February 25, 2023, 9:56pm
#13
SmakToj:
TweenInfo.new()
you didnt set the amount of seconds you want it to last, probably pus something like Tweeninfo.new(1)