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

How come my NPC dialog shop is not working? Someone help?

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

local stats = player:FindFirstChild("leaderstats")
if not stats then return

local money = stats:FindFirstChild("Money")
if not money then return

if choice == script.Parent.DialogChoice.ChoiceA Then
	if money amount >= 0 then
		game.ReplicatedStorage.Fishingtool:clone().Parent = player.Backpack
	end
end)

Error

13:57:56.354 - Workspace.Test Dumb.Head.Dialog.DialogScript:7: unexpected symbol near 'local'

2 answers

✓ Accepted answer

Silly mistakes. I'll just list them off.

  • You forgot an end on line 5

  • You forgot an end on line 8

  • You forgot an end for your event on line 2

  • You capitalized "then" on line 10

  • You didn't index Value for "money" on line 11.

local dialog = script.Parent
local tool = game.ReplicatedStorage.Fishingtool

dialog.DialogChoiceSelected:connect(function(player, choice)
	local stats = player:FindFirstChild("leaderstats")
	if not stats then return end --end
	local money = stats:FindFirstChild("Money")
	if not money then return end --end
	if choice == script.Parent.DialogChoice.ChoiceA then
		if money.Value >= 0 then --index 'value'
			tool:Clone().Parent = player.Backpack
		end
	end
end) --end

You need an end to finish the 'if' statements, and you also need to pay attention to your capitalization. Remember Lua is case-sensitive.


###Problem 1: All 'if' statements need end's to finish them correctly. To fix it in your script, we'll simply add them in where they belong, which is at the end of the statement:

local stats = player:FindFirstChild("leaderstats")
if not stats then return end

local money = stats:FindFirstChild("Money")
if not money then return end

######(You also forgot one on line 13) ###Problem 2: You just made a simple mistake here on line 10. You need to remember to use the correct case for things like this. The 'Then' should be 'then'. Remember to pay attention to this from now on.


##Final Product Ok, so here's the finished script:

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

	local stats = player:FindFirstChild("leaderstats")
	if not stats then return end
	
	local money = stats:FindFirstChild("Money")
	if not money then return end

	if choice == script.Parent.DialogChoice.ChoiceA then
		if money.Value >= 0 then
			game.ReplicatedStorage.Fishingtool:clone().Parent = player.Backpack
		end
	end --You also forgot this end. Remember to use indentations so it's easier to catch mistakes like this as well.
end)

Ok, so now this should work for you :P


Anyways, if you have any further problem/questions, please leave a comment below. Hope I helped :P

####-Dyler3

5 comments

0

ty but now this is a error if money amount >= 0 then the amount part

0

Nvm i just removed it and it worked, Dyler do you have a Steam account you can add me on?

0

Yea, but why Steam?

0

Idk can you add me ? Name is FreezeShot

0

Dyler you going to add me?

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