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

How do I change leaderstats when a certain dialog is used? [UNANSWERED]

Asked by 9 years ago

It's a bit complicated to me, this is what I tried:

function onClick()
    wait(1)
    local enabled = true
    function touchedEffect()
        if not enabled then return end
        if not touchedEffect then return end
        local character = touchedEffect.Parent
        local player = game.Players:GetPlayerFromCharacter(character)
        player.leaderstats.Candy.Value = player.leaderstats.Candy.Value +3
    end
end

if script.Parent.InUse then (onClick)
end

1 answer

Log in to vote
0
Answered by 9 years ago
script.Parent.DialogChoiceSelected:connect(function(player, choice)
    if choice == "I want candy!" then --Just an example of the dialog choice they could have made
        player.leaderstats.Candy.Value = player.leaderstats.Candy.Value + 3
    end
end)

Not quite sure what the touchedEffect was meant for so I don't know what to put there instead.

The DialogChoiceSelected is fired whenever a choice is selected. Let's say they pick the option "I want candy!", it will then check if they picked that and then raise the value of candy by three. If this isn't what you wanted, please elaborate.

NOTE: I am at school and the documentation isn't completely filled out for that event so I am not 100% sure this will work, if it doesn't then when I get home I will update this.

0
It didn't quite work. Please review it when you have a chance. SchonATL 15 — 9y
0
Alright VariadicFunction 335 — 9y
0
What are the errors? VariadicFunction 335 — 9y
Ad

Answer this question