Quest System won't print?

I am trying to make a quest system, but first I got help at hidden developers their answer wasn’t very correct, but they got me somewhere in the middle. The script is located in an NPCs head within a dialog.

The script does not print the choice name, it only does one line (line 1)

I have tried other solutions such as scripting helpers and youtube, but got no good results that worked.

local dialog = script.Parent
    
    dialog.DialogChoiceSelected:Connect(function(p, choice)
        
        print(choice.Name)
        
        if choice == dialog.acc then
            
            p.Stats.questA_active = true
            
        end
        
        if choice == dialog.cancel then
            
            p.Stats.questA_active = false
            
        end
        
    end)
2 Likes

The issue is not clear here, is print(choice.name) not printing?

3 Likes

Yes. Sorry if I didn’t clarify.

2 Likes

Sorry about the delay, is this in a local script or server script? You may have them confused.

Its a server script. 30charsss

That’s the issue. Move it to a local script and if you want to change data values (Like a Shop gives weapons and takes money) use RemoteEvents.

I knew it, but you can only use the DialogChoiceSelected function in a server script.

https://developer.roblox.com/en-us/api-reference/event/Dialog/DialogChoiceSelected

1 Like

I guess todays just opposite day, well, I’ll try this and reply with what happens.

Someone probably already mentioned this, server isn’t in local. Don’t worry pretty simple to chane.

Didn’t work, doesn’t even print anything.
I can’t tell what’s going on anymore.

local dia = script.Parent
local evn = game.ReplicatedStorage.SendQuest

print("test")

dia.DialogChoiceSelected:Connect(function(p,choice)
	
	print("second test")
	print(choice.Name)
	
	if choice == dia.acc then
		
		evn:FireServer("coco","accept")
		
	end
	
	if choice == dia.cancel then
		
		evn:FireServer("coco","cancel")
		
	end
	
	
end)

Strange, ill try to find the issue for this.

Sorry about the EXTREME delay my computer crashed and when I got it working I had forgotten about your issue. So “test” nor "second test’ is printing? Check Output for errors.

Also is this inside a dialog?

Make sure the localscript is in a place it can actually run as well.

1 Like

Can it run inside of a character or inside of a dialog?

Yes it is within a dialog. :slight_smile: chars

does “test” print? Is this your full LocalScript?
If test does print and this is not your full localScript;

Then something is messing up your script that is above “print(test)”

If test does not print and this is your full localScript;
Look in the console for errors

Yes it can…

There are no errors and test does not print and it is my full local script.

We’re going to need the above of the script. It could indicate why “test” hasn’t printed. It could be because a loop hasn’t broken etc. Or as @Syclya mentioned, it could be because the script might not be in the right place.