Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I fix my door script that uses Proximity Prompt?

Asked by 2 years ago

Hello. I am making a game with doors with a keycard system. I have encountered an issue with this; since my door script does not work. When I complete the ProximityPrompt, nothing happens and no error is outputted. No error is outputted when the server starts either.

Here is my code:

local PPS = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")
local door = script.Parent.Parent.Parent.Parent.Door
local tweeningInformation = TweenInfo.new(
    1,
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local doorOpen = {CFrame = CFrame.new(6.25, 3.5, 8.875)}
local doorClose = {CFrame = CFrame.new(0, 3.5, 8.875)}
local tweenOpen = TweenService:Create(door, tweeningInformation, doorOpen)
local tweenClose = TweenService:Create(door, tweeningInformation, doorClose)

function onPromptHoldEnded(promptObject, plr)
    for _, v in pairs(plr:GetChildren()) do
        if v:IsA("Tool") then
            if v.Name == "Level-1 Keycard" or "Level-2 Keycard" or "Level-3 Keycard" or "Level-4 Keycard" or "Level-5 Keycard" or "Level-6 Keycard" then
                script.Parent.Parent.Parent.Screen.Screen.TextLabel.TextColor3 = Color3.fromRGB(0,255,0)
                script.Parent.Parent.Parent.Screen.Screen.TextLabel.Text = "ACCESS GRANTED"
                tweenOpen:Play()
                wait(2)
                script.Parent.Parent.Parent.Screen.Screen.TextLabel.TextColor3 = Color3.fromRGB(255,255,255)
                script.Parent.Parent.Parent.Screen.Screen.TextLabel.Text = "Level-1 Required."
                tweenClose:Play()
            else
                script.Parent.Parent.Parent.Screen.Screen.TextLabel.TextColor3 = Color3.fromRGB(255,0,0)
                script.Parent.Parent.Parent.Screen.Screen.TextLabel.Text = "ACCESS DENIED"
                wait(2)
                script.Parent.Parent.Parent.Screen.Screen.TextLabel.TextColor3 = Color3.fromRGB(255,255,255)
                script.Parent.Parent.Parent.Screen.Screen.TextLabel.Text = "Level-1 Required."
            end
        end
    end
end

PPS.PromptButtonHoldEnded:Connect(onPromptHoldEnded)

1 answer

Log in to vote
0
Answered by 2 years ago

try using this instead. This event fires whenever the hold finishes so yeah.

PPS.Triggered:Connect(onPromptHoldEnded)
0
Threw am error. 'Triggered is not a valid member of ProximityPromptService "ProximityPromptService"' PufferfishDev 49 — 2y
Ad

Answer this question