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

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

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

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.

3 comments

0

It didn't quite work. Please review it when you have a chance.

0

Alright

0

What are the errors?

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