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

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

Asked by 8 years ago
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

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

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
Ad
Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
8 years ago

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

0
ty but now this is a error if money amount >= 0 then the amount part jo3thebomb 12 — 8y
0
Nvm i just removed it and it worked, Dyler do you have a Steam account you can add me on? jo3thebomb 12 — 8y
0
Yea, but why Steam? dyler3 1510 — 8y
0
Idk can you add me ? Name is FreezeShot jo3thebomb 12 — 8y
0
Dyler you going to add me? jo3thebomb 12 — 8y

Answer this question