So, I have an if statement that checks if the player has a key, and if the player doesn't have it, it plays a sound. But I have the key and the door doesn't open. The script is also a local script.
game.Players.LocalPlayer.CharacterAdded:Wait()
local Door = workspace.Door.MyBigPPpart
local d = false
local TweenService = game:GetService("TweenService")
Door.ProximityPrompt.Triggered:Connect(function(player)
if not d then
d = true
local anim = player.Character.Humanoid:LoadAnimation(script.Pickup)
anim:Play()
if not player.Backpack:FindFirstChild("Door1Key") or not player.Character:FindFirstChild("Door1Key") then
Door.Lock:Play()
elseif player.Backpack:FindFirstChild("Door1Key") or player.Character:FindFirstChild("Door1Key") then
local info = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
local goals = {
Position = Vector3.new(470.108, -19.667, 1597.603);
Orientation = Vector3.new(0, 90, 0)
}
local ts = TweenService:Create(Door.Parent.Door1, info, goals)
ts:Play()
local info1 = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
local goals1 = {
Position = Vector3.new(481.541, -19.667, 1597.603);
Orientation = Vector3.new(0, -90, 0)
}
local ts1 = TweenService:Create(Door.Parent.Door2, info1, goals1)
ts1:Play()
Door.Open:Play()
end
wait(1)
d = false
end
end)
