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

Dialog not Spawning Ship?

Asked by 6 years ago

So i'm making an NPC that you speak to in order to spawn a ship and have been having a large number of issues with it. This is my current set up

local Chat = script.Parent
local ChatContainer = Chat.DialogContainer
local Information = Chat.Information

local DataHolder = game.ReplicatedStorage.DataFolder

local ShipToSpawn = nil

script.Parent.DialogChoiceSelected:connect(function(Player, Choice)
    local Data = DataHolder:FindFirstChild(Player.Name.."Data")

    --[[
        When you hit Request Purchase, it'll move in the available options into Dialog1 so that it's change-able via moving stuff in the folers and not
        touching the script for quicker changes later on.
    --]]    


    if Choice == Chat.RequestPurchase then
        -- Move the buy options into the dialog
        Information.SpawnButtons.RemoteEvent:FireClient(Chat)
    else
        -- The Choice was something else.
        local ShipName = false
        local NameCheck = ""
            for Num, Check in pairs(ChatContainer:GetChildren()) do
                if Choice.Name == Check.Name then
                    ShipName = true
                    NameCheck = Check.Name
                    ShipToSpawn = Information.ShipHolder.Value[Check.Name]

                    if Data.Berry.Value >= Information[NameCheck.."_Price"].Value then
                        Data.Berry.Value = Data.Berry.Value - Information[NameCheck.."_Price"].Value
                        Information.SpawnShip.Ship.Value = ShipToSpawn
                        Information.SpawnShip.RemoteEvent:FireServer()
                    else
                        -- You broke.
                    end     
                end
            end 
    end 
end)

My issue lies in where I run

Information.SpawnButtons.RemoteEvent:FireClient(Chat)

It's for another ServerScript I have with this code

function SpawnButtons()
    local ChatContainer = script.Parent.Parent.DialogContainer
    local Information = script.Parent.Parent.Information
    local Chat = script.Parent.Parent
    for Num, Obj in pairs(ChatContainer:GetChildren()) do
            if Chat.RequestPurchase.Dialog1:FindFirstChild(Obj.Name) then
                game.Debris:AddItem(Chat.RequestPurchase.Dialog1[Obj.Name],0)
            end
            local FindPrice = Information[Obj.Name.."_Price"]
            local CloneDialog = Obj:clone()
                CloneDialog.UserDialog = Obj.Name..": "..FindPrice.Value
                CloneDialog.Parent = Chat.RequestPurchase.Dialog1           
        end
end
script.RemoteEvent.OnClientEvent:connect(SpawnButtons)

and yes before you say something about it being OnClientEvent, I've tried it with both client and server. This is just what it was left at when I was messing with it

I've been messing with this all day trying to get it. I have filtering enabled on and I don't have too much experience with it.

The end goal for this script is for when you speak to the NPC, it'll input the DialogChoices into the conversation based on what's in a folder so I don't need to alter the script at all later on and can just add to a folder. Then spawn the ship that you select.

Currently it stops too early.

0
So you're trying to use :FireClient() onto a server script? :FireClient() only works when you're trying to fire that onto a localscript. User#20279 0 — 6y

Answer this question