Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Dialog Shop works in studio, not in game. Is this a LocalScript/Script issue?

I need a classic dialog shop for my game, and I found this script that works perfectly well in studio, but when I play online, I don't get what I asked for.

I think the problem is that the script I'm using is a Script and not a LocalScript, but when I put this into a LocalScript, it didn't work even in studio. This is just my amateur opinion, but I think it has something to do with the line gun.Parent=player.Backpack Maybe it doesn't know who player is when online?

script.Parent.DialogChoiceSelected:connect(function(player, choice)
    if (choice == script.Parent.Choice1) then
        gun = game.Lighting["Coffee"]:clone() --The exact name of the tool/weapon the player will get.
        print "Cloned Coffee"
        gun.Parent = player.Backpack
        script.Parent.Choice1.ResponseDialog = "Sure!" 
    end

    if (choice == script.Parent.Choice2) then
         gun = game.Lighting["Pretty Good Snax "]:clone() --The exact name of the tool/weapon the player will get.                                                                                                                                                                                          Print "Snax"
        gun.Parent = player.Backpack
        script.Parent.Choice1.ResponseDialog = "Sure!" 
    end

    if (choice == script.Parent.Choice3) then
        gun = game.Lighting["Expired Elixir"]:clone() --The exact name of the tool/weapon the player will get. 
        gun.Parent = player.Backpack
        script.Parent.Choice1.ResponseDialog = "Sure...!"
    end

    if (choice == script.Parent.Choice4) then
        gun = game.Lighting[" "]:clone() --The exact name of the tool/weapon the player will get.
        gun.Parent = player.Backpack
        script.Parent.Choice1.ResponseDialog = "Sorry...!" 
    end
end)

1 answer

I don't know if this will work, but I have cleaned it up a bit and I suggest refraining from naming something " ". Giving this a name may help as well. If there is no item then you can delete the if statement as a whole.

script.Parent.DialogChoiceSelected:connect(function(player, choice)
    if (choice == script.Parent.Choice1) then
        local coffee = game.Lighting["Coffee"]:Clone().Parent. = player.Backpack
        print ("Cloned Coffee")
        script.Parent.Choice1.ResponseDialog = "Sure!" 
    end

    if (choice == script.Parent.Choice2) then
         local snax = game.Lighting["Pretty Good Snax "]:Clone().Parent = player.Backpack                                                                                                                                                                                   		
        print ("Snax")
        script.Parent.Choice1.ResponseDialog = "Sure!" 
    end

    if (choice == script.Parent.Choice3) then
       local eelixir = game.Lighting["Expired Elixir"]:Clone().Parent = player.Backpack 
        script.Parent.Choice1.ResponseDialog = "Sure...!"
    end

    if (choice == script.Parent.Choice4) then
        local idk = game.Lighting[" "]:Clone().Parent = player.Backpack
        script.Parent.Choice1.ResponseDialog = "Sorry...!" 
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.