alright so, I am having problem with a proximity prompt issue, I have a script which makes the door open when you hold the specified key with the prompt, but when the prompt is placed into an attachment it does not work, prompt shows but it doesn’t open the door when you hold the key.
If the proximity prompt is not working make sure the attachment is parented to a part and make sure the script that handles the proximity prompt looks like this: (just make sure that you got the .Triggered function, the rest is not even that necessary)
script.Parent.Triggered:Connect(function(player)
if player and player == game.Players:FindFirstChild(player.Name) then
print("triggered by " ..player.DisplayName)
-- door open function
end
end)
It did not work, unless I am doing something wrong. Here is the script
local tween = game:GetService("TweenService")
local door = script.Parent
local ocf = door.CFrame
local open = tween:Create(door, TweenInfo.new(2, Enum.EasingStyle.Exponential), {Position = ocf * Vector3.new( -5, 0, 0)})
local close = tween:Create(door, TweenInfo.new(2, Enum.EasingStyle.Exponential), {Position = ocf * Vector3.new(0, 0, -0) })
local debounce = false
local ProximityPrompt = script.Parent.Attachment.ProximityPrompt
ProximityPrompt.Triggered:Connect(function(player)
if player.Backpack:FindFirstChild("GES-1") or player.Backpack:FindFirstChild("GES-2") or player.Backpack:FindFirstChild("GES-3") or player.Backpack:FindFirstChild("GES-4") or player.Backpack:FindFirstChild("GES-5") or player.Backpack:FindFirstChild("GES-0") then
debounce = true
script.Parent.ProximityPrompt.Enabled = false
open:Play()
script.Parent.AccessGranted:Play()
script.Parent.DoorOpen:Play()
wait(7)
close:Play()
script.Parent.DoorClose:Play()
wait(3)
script.Parent.ProximityPrompt.Enabled = true
debounce = false
end
end)
local tween = game:GetService("TweenService")
local door = script.Parent
local ocf = door.CFrame
local open = tween:Create(door, TweenInfo.new(2, Enum.EasingStyle.Exponential), {Position = ocf * Vector3.new( -5, 0, 0)})
local close = tween:Create(door, TweenInfo.new(2, Enum.EasingStyle.Exponential), {Position = ocf * Vector3.new(0, 0, -0) })
local debounce = true
local ProximityPrompt = script.Parent.Attachment.ProximityPrompt
ProximityPrompt.Triggered:Connect(function(player)
if player and player == game.Players:FindFirstChild(player.Name) and player.Backpack:FindFirstChild("GES-1") or player.Backpack:FindFirstChild("GES-2") or player.Backpack:FindFirstChild("GES-3") or player.Backpack:FindFirstChild("GES-4") or player.Backpack:FindFirstChild("GES-5") or player.Backpack:FindFirstChild("GES-0") then
if debounce == true then
debounce = false
open:Play()
script.Parent.AccessGranted:Play()
script.Parent.DoorOpen:Play()
wait(7)
close:Play()
script.Parent.DoorClose:Play()
wait(3)
debounce = true
end
end
end)
while wait() do
if debounce == true then
ProximityPrompt.Enabled = true
else
ProximityPrompt.Enabled = false
end
end
try this just for testing.
EDIT: forgot to say, the function that will happen is gonna be non-local so the function happens for everyone in the server, not only for the player. If you want to change this put everything in a local script and modify the instances.
Proximitypromt isnt defined correctly right?
If the script you’ve shown is parented to the proximitypromt it should be script.Parent, if its the one called DoorScript it should be script.Parent.ProximityPrompt