So, I'm trying to write a script that will assign different strings in the ResponseDialog of five DialogChoices, based on the player's TeamColor and the "Cash" value in their Cash Gui. Currently, the script works as planned in Edit > Play, but when I do a server test, the DialogChoices give the default ResponseDialog, rather than what the script assigns to them. I've tried monitoring the ResponseDialog of the DialogChoice while doing a server test, and I've found that the ResponseDialog changes to the desired string AFTER the DialogChoice gives the ResponseDialog. I've looked on the Roblox Wiki and I've checked with similar forum posts, but nothing seems to help. Does anyone know how to fix this?
Here's the current script:
for _,v in pairs (game.ReplicatedStorage.Weapons:GetChildren()) do weps = v.Name print("Guns Script: "..weps) end Weapons = game.ReplicatedStorage.Weapons local dialog1 = script.Parent dialog1.DialogChoiceSelected:connect(function(player, choice) if player.TeamColor == BrickColor.new("Black") then script.Parent.Gun.ResponseDialog = "You came to the right place. How can I be of assistance?" for _,i in pairs (dialog1.Choices:GetChildren()) do i:Clone() i.Parent = dialog1.Gun end if choice.Name == "Choice1" then local dialog2 = script.Parent.Gun if player.PlayerGui.Cash.Cash.Value >= 500 then print("Player Money: "..player.PlayerGui.Cash.Cash.Value) dialog2.Choice1.ResponseDialog = "Sure, pal. Thanks for the business." local pistol = Weapons.pistol:Clone() pistol.Parent = player.Backpack pistol.Name = "Concealed Firearm" player.PlayerGui.Cash.Cash.Value = (player.PlayerGui.Cash.Cash.Value - 500) else dialog2.Choice1.ResponseDialog = "Not unless you have $500." end end if choice.Name == "Choice2" then local dialog3 = script.Parent.Gun if player.PlayerGui.Cash.Cash.Value >= 5000 then print("Player Money: "..player.PlayerGui.Cash.Cash.Value) dialog3.Choice2.ResponseDialog = "Alright. Try this on for size." local smg = Weapons.smg:Clone() smg.Parent = player.Backpack smg.Name = "MP5K" player.PlayerGui.Cash.Cash.Value = (player.PlayerGui.Cash.Cash.Value - 5000) else dialog3.Choice2.ResponseDialog = "Sure thing. Find $5000, and get back to me." end end if choice.Name == "Choice3" then local dialog3 = script.Parent.Gun if player.PlayerGui.Cash.Cash.Value >= 100 then print("Player Money: "..player.PlayerGui.Cash.Cash.Value) dialog3.Choice3.ResponseDialog = "How about one of my signature switchblades?" local knife = Weapons.knife:Clone() knife.Parent = player.Backpack knife.Name = "Switch Blade" player.PlayerGui.Cash.Cash.Value = (player.PlayerGui.Cash.Cash.Value - 100) else dialog3.Choice3.ResponseDialog = "If you can get your hands on $100, then yes." end end if choice.Name == "Choice4" then local dialog4 = script.Parent.Gun if player.PlayerGui.Cash.Cash.Value >= 200 then print("Player Money: "..player.PlayerGui.Cash.Cash.Value) dialog4.Choice4.ResponseDialog = "Here you go. Don't get too cocky, though - I'm not a very good artist." local badge = Weapons.badge:Clone() badge.Parent = player.Backpack badge.Name = "Counterfeit ID Badge" player.PlayerGui.Cash.Cash.Value = (player.PlayerGui.Cash.Cash.Value - 200) else dialog4.Choice4.ResponseDialog = "Get $200, then I'll be happy to help you." end end else script.Parent.Gun.ResponseDialog = "As a matter of fact, I'm not. Now get outta my face." for _,v in pairs (dialog1.Gun:GetChildren()) do if v ~= nil then print(v) v:Destroy() end end end end)
If it helps, here's the hierarchy of the Dialog, the Weapons, and the Cash Gui, with the above script highlighted in red:
http://prntscr.com/7jl4cb http://prntscr.com/7jl4e8 http://prntscr.com/7jl4fz
If need be, I'd be happy to lend anyone the objects listed above if it helps them understand the script or find a solution.