Ad
Log in to vote
-1

How could I make this script function correctly?

Asked by 7 years ago

local dialog = script.Parent dialog.DialogChoiceSelected:connect(function(player, choice) -- Check the player has a stats object local stats = player:FindFirstChild('leaderstats') if not stats then return end

-- And that the stats object contains a gold member
local gold = stats:FindFirstChild('Gold')
if not gold then return end

if choice == script.Parent.DialogChoice.ChoiceA then
    if gold.Value >= 5 then -- 5 is the amount of gold you need to purchase this weapon
        game.ReplicatedStorage.Weapon1:Clone().Parent = player.Backpack

game.ReplicatedStorage.Weapon1:Clone().Parent = player.StarterPack gold.Value = gold.Value - 5 -- subtract the amount of gold you need to purchase end elseif choice == dialog.DialogChoice.ChoiceB then if gold.Value >= 10 then game.ReplicatedStorage.Weapon2:Clone().Parent = player.Backpack game.ReplicatedStorage.Weapon2:Clone().Parent = player.StarterPack gold.Value = gold.Value - 10 end elseif choice == dialog.DialogChoice.ChoiceC then if gold.Value >= 15 then game.ReplicatedStorage.Weapon3:Clone().Parent = player.Backpack game.ReplicatedStorage.Weapon3:Clone().Parent = player.StarterPack gold.Value = gold.Value - 15 end end end)

0
Sorry Its a bit messy. coldice231 45 — 7y
0
Can anyone help me fix it so it will work? coldice231 45 — 7y
0
It looks like it already does function correctly. We wouldn't know that for sure, though, since you haven't contrasted your intent for how this is meant to function with how it actually does. 1waffle1 2908 — 7y
0
It is meant to function if you buy a weapon from from the dialog shop using the leaderstat Gold you get from kills then it will be cloned into your starterPack so you will have it until you leave. Anything wrong in the way I'm using it? coldice231 45 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

nothing wrong if there is a mistake it is that you have to changeif choice == script.Parent.DialogChoice.ChoiceA then into if choice == script.Parent.DialogChoice.nameofdialogsetting then change nameofdialogsetting to the name of it or rename the setting or it functions fine or you have wrong name where ChoiceA is.

Ad

Answer this question