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

How would I go about scripting a Choice within a Choice (Dialog)?

Asked by
Xl5Xl5 65
8 years ago

So if Choice1 is selected, if the player has more than so and so rep then create a new choice via this script. please help, link me to a wiki also that will help me with dialogs

script.Parent.DialogChoiceSelected:connect(function(player,choice)

  local humanoid = player.Character:findFirstChild("Humanoid")

    if not humanoid then return end --End the function if the humanoid isn't found
local stats = player:FindFirstChild('leaderstats')
    if not stats then return end
local rep = stats:FindFirstChild('Reputation')
    if not rep then return end

    if choice.Name == "Choice1" then
        wait(1)
rep.Value = rep.Value + 2 

    elseif choice.Name == "Choice2" then
        wait(1)
rep.Value = rep.Value + 1

elseif choice.Name == "Choice3" then
        wait(1)
rep.Value = rep.Value - 1
    end

end)

1 answer

Log in to vote
0
Answered by
Marios2 360 Moderation Voter
8 years ago

First off, lines 7 and 9, along with FindFirstChild at lines 6 and 8, are useless, unless you don't add those right after a Player instance is added. Second, findFirstChild is deprecated (but you may have put that one by mistake judging by lines 7 and 9)

Here's the improved script you inputted:

script.Parent.DialogChoiceSelected:connect(function(player,choice)
    if not player.Character:FindFirstChild("Humanoid") then return end --End the function if the humanoid isn't found
local stats = player.leaderstats
local rep = stats.Reputation
    if choice.Name == "Choice1" then
        wait(1)
rep.Value = rep.Value + 2 
    elseif choice.Name == "Choice2" then
        wait(1)
rep.Value = rep.Value + 1
elseif choice.Name == "Choice3" then
        wait(1)
rep.Value = rep.Value - 1
    end
end)

Third, here's the idea, at another script in the main Dialog instance:

script.Parent.Changed:connect(function(property)
    script.Parent:FindFirstChild("Choice4"):Destroy() --Remove locked choices initially
    if workspace[property] == true then
        local player = script.Parent.Parent.Player.Value --In a LocalScript, get the player to change that value
        if player.leaderstats.Reputation.Value >= 5 then
            local choice = Instance.new("DialogChoice", script.Parent) --Makes a DialogChoice parented to Dialog
            choice.Name = "Choice4"
            choice.PlayerDialog = "Lololol u so nub"
            choice.ResponseDialog =  "You are such a huge jerk sometimes, you know..."
        end
    end
end)

The rest is up to you. Hope i helped!

HOLD IT! Referring to the returned property itself doesn't do much when you refer to it without property; you instead refer to it's value otherwise. So, instead, use

if workspace[property] == true then

as InUse (or however that property was to called) will probably be the only property that changes that is a boolean.

0
thank you so much! Xl5Xl5 65 — 8y
0
WAIT! I have edited my answer so it actually works Humanoid-side. Update your script to that! Marios2 360 — 8y
Ad

Answer this question