Hey, so i feel really stupid however for some reason i am unable to get the players backpack to check for a tool. If the player has this tool then they will be able to open the door. If not then they can’t open the door.
Code:
local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")
function PromptTriggered(Prompt)
if Prompt.Name == "DoorPrompt" then
Prompt.Enabled = false
local Door = Prompt.Parent.Parent.DoorModel.PrimaryPart
local Tween = TweenService:Create(Door, TweenInfo.new(2), {CFrame = Door.CFrame * CFrame.new(Door.Size.Y * 0, 10, 0)})
Tween:Play()
local function TweenCompleted()
task.wait(4)
local ClosingTween = TweenService:Create(Door, TweenInfo.new(2), {CFrame = Door.CFrame * CFrame.new(Door.Size.Y * 0, -10, 0)})
ClosingTween:Play()
local function ClosingTweenCompleted()
Prompt.Enabled = true
end
ClosingTween.Completed:Connect(ClosingTweenCompleted)
end
Tween.Completed:Connect(TweenCompleted)
end
end
ProximityPromptService.PromptTriggered:Connect(PromptTriggered)
Thanks for the fast reply, however i try to implement this but it does not appear to work. How should i implement it within my script? I keep getting errors with my current "end"s
Ah, sorry. I see what you were doing. Then you can also use PromptTriggered:
ProxomityPromptService.PromptTriggered:Connect(function(prompt,player)
if prompt.Name == 'DoorPrompt' and player.Backpack:FindFirstChild('Keycard Name') then
-- code to open door
end
end)
You’ll of course have to appropriately assign the variables.