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

FE Dialog not working on server?

Asked by
Rhidlor 42
6 years ago
Edited 6 years ago

So I'll start off by explaining how I have my Dialog setup; I have the Dialog in an npc's head in the Workspace, the following code is inside a Script inside the Dialog. The script works locally but not on a server. I've been told that I should be handling this locally but I have no idea how I would do so. Any and all help is greatly appreciated!

Edit: I forgot to specify what wasn't working, the print on line 11 and everything following it isn't firing on the server

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ManipulateStoreEvent = ReplicatedStorage.RemoteEvents:WaitForChild("ManipulateStoreEvent")

local ShopKeeper = script.Parent.Parent.Parent
local Position = ShopKeeper.HumanoidRootPart.CFrame.p
local Dialog = script.Parent
local PlayersUsing = {}

script.Parent.DialogChoiceSelected:Connect(function(Player, DialogChoice)
    if DialogChoice.Name == "Yes" then
        print("Attempting to open " .. Player.Name .. "'s shop")
        ManipulateStoreEvent:FireClient(Player, "Open")
        table.insert(PlayersUsing, Player)
    end
end)

function getPlayerPosition(Player)
    local Character = game.Workspace:FindFirstChild(Player.Name)
    if Character then
        return Character.HumanoidRootPart.CFrame.p
    end
end

function removePlayerFromPlayersUsing(PlayerRemoving)
    for Index, Player in pairs(PlayersUsing) do
        if PlayerRemoving == Player then
            table.remove(PlayersUsing, Index)
        end
    end
end

while wait(0.5) do
    if Dialog.InUse then
        for _, Player in pairs(PlayersUsing) do
            local Magnitude = (Position - getPlayerPosition(Player)).magnitude 
            if Magnitude > Dialog.ConversationDistance then
                print("Attempting to close " .. Player.Name .. "'s shop")
                ManipulateStoreEvent:FireClient(Player, "Close")
                removePlayerFromPlayersUsing(Player)
            end
        end
    end
end

1 answer

Log in to vote
0
Answered by 6 years ago

Your problem is that you are trying to compare the name of the dialog choice, but instead you should be comparing the UserDialog property of it.

Just replace the function you have to this: (you'll know which one)

script.Parent.DialogChoiceSelected:Connect(function(Player, DialogChoice)
    if DialogChoice.UserDialog == "Yes" then
        print("Attempting to open " .. Player.Name .. "'s shop")
        ManipulateStoreEvent:FireClient(Player, "Open")
        table.insert(PlayersUsing, Player)
    end
end)

If anything else doesn't work, let me know.

0
Also remember the DialogChoiceSelected event is only for dialogs, not dialogchoices. Operation_Meme 890 — 6y
0
I personally didn't get this working, I opted to create my own custom dialog because I figured it would allow for more functionality and creativity. But I've been informed this is working for other individuals. Rhidlor 42 — 6y
Ad

Answer this question