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

How to stop and destroy Dialog?

Asked by 7 years ago
Edited 7 years ago

I have some blocks, that you can speak with they, and if you select a specific choice, the block must be destroy, I make an understandable extract of the code

LOCAL SCRIPT:

NOTE: this is a Local Script of a tool

local dialog = tool:WaitForChild("MaterialsDialog") --the dialog
local clonedDialog --a variable to clone the dialog
--this is the function to use the dialog
--and acctualy, this only call the server, and send the object
local function choiceFunction(choice, object)
    if tostring(choice) == "Yes" then
        exchangeWoodForMaterials:InvokeServer(object)
    end
end
local function onEquip()
    --NOTE: the getPlayerStuff:InvokeServer(), give the array of objects
    for _, object in ipairs(getPlayerStuff:InvokeServer()) do
        if object.Name == "PlainTable" then
            --clone the dialog
            clonedDialog = dialog:Clone()
            --set the dialog to the object
            clonedDialog.Parent = object
            --set the interface to the dialog
            clonedDialog.DialogChoiceSelected:connect(
                function(_, choice)     
                    choiceFunction(choice, object) 
                end)
        end
    end
end

SERVER SCRIPT

local exchangeWoodForMaterials = --new RemoteFunction
function exchangeWoodForMaterials.OnServerInvoke(player, object)
    --get the price of the object
    local price = buildingMotor:GetPrice(object.Name)
    --give the player the price
    managerDataStorage:ChangeStat(player, "Materials", price) 
    object:Destroy() --destroy the object
end

and, I got this error:

partOrCharacter must be in the Workspace

Stack Begin

Script 'CoreGui.RobloxGui.CoreScripts/MainBotChatScript2', Line 304 - upvalue chatFunc

Script 'CoreGui.RobloxGui.CoreScripts/MainBotChatScript2', Line 323 - global selectChoice

Script 'CoreGui.RobloxGui.CoreScripts/MainBotChatScript2', Line 348

Stack End

I need to stop the Dialog or destroy, acctualy, the Dialog it's going to be destroy anyway.

Any help will be appreciated.

0
Can you include the script. User#5423 17 — 7y
0
I am going to make an understandable extract LordSalchipapas 96 — 7y

Answer this question