Ad
Log in to vote
0

Proximity Trigger not working anymore?

Asked by 16 days ago

My proximity trigger used to work. It was always working but now, it doesn't work anymore.

I searched online but that didn't help so now I have to do this.

Code:

( Its a big one. Scroll down until you see, .Triggered )

local ChatService = game:GetService("Chat")
local ServerStorage = game:GetService("ServerStorage")
local Remotes = game:GetService("ReplicatedStorage").Remotes
local Rep = game:GetService("ReplicatedStorage")

local talkpart = script.Parent.Parent

local AIstarted = false
local connection
local connection2
local connection3

local shownPassport = false
local conversationgoingon = false

local StandClass = 'FC'

function nameGenerator(gender)
    local BoyNames = {
        "Dan", "Jonathan", "James", "Jack", 'Tom', "Lorenzo", "Philip", "Kacper", "Daryl", "Timmothy", "Bob", "Ben", "Walsher", "Rod", "Sean"
    }
    local GirlNames = {
        "Mary", 'Theresa', "Felicia", "Karina", "Lia", "Amanda", "Alexandra", "Penelope", "Catherine", "Ellie", "Daisy"
    }

    if gender == "Boy" then
        return BoyNames[math.floor(math.random(1, #BoyNames))]
    end
    if gender == "Girl" then
        return GirlNames[math.floor(math.random(1,#GirlNames))]
    end
end

local chosenName = nameGenerator("Boy")

function giveBoardingPass(plr)
    for i, v in pairs(ServerStorage.BoardingPasses:GetChildren()) do
        if v.TypeOfClass.Value == StandClass then
            local clonedBP = v:Clone()
            clonedBP.Parent = plr.Backpack
        end
    end
end

script.Parent.Triggered:Connect(function(plr)
    print("triggered")
    if conversationgoingon == false then
        if plr.Backpack:FindFirstChild("Ticket") == nil then
            conversationgoingon = true
            ChatService:Chat(talkpart, "Greetings, call me " .. chosenName .. ". Please show your passport for this flight." , Enum.ChatColor.Green)
            plr.Backpack.Passport.Equipped:Connect(function()
                if shownPassport == false then
                    shownPassport = true
                    wait(1)
                    ChatService:Chat(talkpart, "Thank you, " .. plr.DisplayName .. "." , Enum.ChatColor.Green)
                    wait(3)
                    ChatService:Chat(talkpart, "Now, have you booked already or not ?" , Enum.ChatColor.Green)
                    connection = plr.Chatted:Connect(function(msg)
                        --- Tier 1 ---
                        local Message = string.lower(msg)
                        if string.find(Message, "yes")  ~= nil then
                            connection:Disconnect()
                            ChatService:Chat(talkpart, "If you have questions, please locate your nearst information desk.", Enum.ChatColor.Green)

                            shownPassport = false
                            conversationgoingon = false

                        elseif string.find(Message, "no") then

                            wait(2)
                            ChatService:Chat(talkpart, "You are flying with First Class for this flight. Please pay $250. If you have any special cards. Please show now. Say 'Okay' to start transaction." , Enum.ChatColor.Green)
                            connection2 = plr.Chatted:Connect(function(msg2)
                                --- Tier 2 (Transaction) ---
                                connection:Disconnect()
                                local Message2 = string.lower(msg2)
                                print("Said " .. Message2)

                                if string.find(Message2, "okay") then 
                                    connection2:Disconnect()
                                    print("paid")
                                    plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 250
                                    if plr.leaderstats.Cash.Value > 0 then
                                        wait(2)
                                        ChatService:Chat(talkpart, "Your transaction is approved. Here is your boarding pass. And the departure gate is " ..  require(Rep.GameValues).gate .. ".", Enum.ChatColor.Green)
                                        giveBoardingPass(plr)

                                        shownPassport = false
                                        conversationgoingon = false
                                    else
                                        plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 250
                                        ChatService:Chat(talkpart, "Your transaction is declined. Try again with more cash, or fly with a different class.", Enum.ChatColor.Green)

                                        shownPassport = false
                                        conversationgoingon = false

                                    end
                                else
                                    ChatService:Chat(talkpart, "I don't understand you. Please state your answer differently." , Enum.ChatColor.Green)
                                end
                            end)
                        else
                            ChatService:Chat(talkpart, "I don't understand you. Please state your answer differently." , Enum.ChatColor.Green)
                        end
                    end)
                end
            end)
        else
            ChatService:Chat(talkpart, "Greetings. Are you here for a refund?" , Enum.ChatColor.Green)
            connection3 = plr.Chatted:Connect(function(msg3)
                local Message3 = string.lower(msg3)

                if string.find(Message3, "yes") then
                    connection3:Disconnect()
                    ChatService:Chat(talkpart, "Here is your refund." , Enum.ChatColor.Green)
                    wait(1.5)
                    ChatService:Chat(talkpart, "Unfortunately, you don't get the full amount of the price you paid." , Enum.ChatColor.Green)
                    plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 175

                    shownPassport = false
                    conversationgoingon = false
                end
            end)
        end
        end
    end
end)
0
Did you add new code and then it stopped working?? If that is the case, its because something is wrong with the script. theking66hayday 148 — 16d
0
Can you show us the output? ryanzhzh 113 — 16d
0
No output. Brioche_Noodle 45 — 15d
0
Well yeah I’d did but i doubt it would break the script as it is just a listener. Brioche_Noodle 45 — 15d
View all comments (2 more)
0
.Triggered works when the proximity prompt has hold duration of 0. Maybe you changed the duration? SuperPuiu 482 — 15d
0
Wait nevermind there was something wrong with the end so now its solved. Brioche_Noodle 45 — 15d

Answer this question