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

Door won't play animation when activated? [SOLVED]

I am working on a door that plays an opening animation when you scan your finger print with a proximity prompt. The door animation won't play but there is nothing in the output. This is a normal script inside the door model. Please help, thanks!

local DoorModel = script.Parent.Door
local FingerScan = script.Parent.FingerScanner.Scan.ProximityPrompt
local activated = false
local TweenService = game:GetService("TweenService")

local tweeninfo = TweenInfo.new(	
	DoorModel.Speed.Value,
	Enum.EasingStyle.Quart,
	Enum.EasingDirection.Out,
	0,
	true,
	0	
)

local function open(OtherPart)
	local Player = game.Players:FindFirstChild(OtherPart.Parent.Name)
	if Player and not activated then
		
		activated = true
		
		local TweenDoor = TweenService:Create(DoorModel.Main, tweeninfo, {Position = DoorModel.Target3.Position})
		local TweenDoor1 = TweenService:Create(DoorModel.Main, tweeninfo, {Position = DoorModel.Target1.Position})
		local TweenDoor2 = TweenService:Create(DoorModel.Main, tweeninfo, {Position = DoorModel.Target2.Position})
		
		TweenDoor1:Play()
		wait(0.5)
		TweenDoor2:Play()
		TweenDoor.Completed:Wait()
		wait(2)
		
		TweenDoor1:Play()
		wait(0.5)
		TweenDoor:Play()
		TweenDoor.Completed:Wait()
		wait(2)
		
		activated = false
	end
end

FingerScan.Triggered:Connect(open)

1 answer

✓ Accepted answer

Hey! I'm not entirely sure but I think the problem with the script and the reason the animation doesn't show is at line 16 & line 17 as you stated in line 16 that game.Players:FindFirstChild(OtherPart.Parent.Name) but I'm pretty sure ROBLOX's ProximityPrompt returns a player instance on the event Triggered.

And at line 17 you state you're trying to find the player's parent's name meaning it tries to find game.Players in game.Players

(Simple Fix) : Just change Find on line 16

But as I see you don't even really need a player check as it's not a touch, only players can activate a proximity prompt.

Here is what I'm talking about :

local DoorModel = script.Parent.Door
local FingerScan = script.Parent.FingerScanner.Scan.ProximityPrompt
local activated = false
local TweenService = game:GetService("TweenService")

local tweeninfo = TweenInfo.new(    
    DoorModel.Speed.Value,
    Enum.EasingStyle.Quart,
    Enum.EasingDirection.Out,
    0,
    true,
    0   
)

local function open()
    if not activated then

        activated = true

        local TweenDoor = TweenService:Create(DoorModel.Main, tweeninfo, {Position = DoorModel.Target3.Position})
        local TweenDoor1 = TweenService:Create(DoorModel.Main, tweeninfo, {Position = DoorModel.Target1.Position})
        local TweenDoor2 = TweenService:Create(DoorModel.Main, tweeninfo, {Position = DoorModel.Target2.Position})

        TweenDoor1:Play()
        wait(0.5)
        TweenDoor2:Play()
        TweenDoor.Completed:Wait()
        wait(2)

        TweenDoor1:Play()
        wait(0.5)
        TweenDoor:Play()
        TweenDoor.Completed:Wait()
        wait(2)

        activated = false
    end
end

FingerScan.Triggered:Connect(open)

1 comment

0

Thank you! The script works now. :)

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