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

My Script isnt working, how to fix it?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

This is a Buying script but its not working how could I fix this?

local figure = script.Parent
local shop = figure.Parent
local dialog = figure.Head.Dialog
local items = shop.Items
currency = "Cash"
keepOnDeath = true


--/main\
d = dialog:GetChildren()
for i = 1,#d do
    d[i].UserDialog = ""..d[i].ItemName.Value.." for "..d[i].Cost.Value.." "..currency..""
end
function arm_GiveEffect(LA,RA)
    a = LA.CFrame
    b = RA.CFrame
    for i = 0,1.5,0.1 do
        wait(0.025)
        LA.CFrame = LA.CFrame*CFrame.fromEulerAnglesXYZ(0.1,-0.03,0)*CFrame.new(0,0,-0.05)
        RA.CFrame = RA.CFrame*CFrame.fromEulerAnglesXYZ(0.1,0.03,0)*CFrame.new(0,0,-0.05)
    end
    wait(0.025)
    for i = 0,1.5,0.1 do
        wait(0.025)
        LA.CFrame = LA.CFrame*CFrame.fromEulerAnglesXYZ(-0.1,0.03,0)*CFrame.new(0,0,0.05)
        RA.CFrame = RA.CFrame*CFrame.fromEulerAnglesXYZ(-0.1,-0.03,0)*CFrame.new(0,0,0.05)
    end
    wait(0.025)
    LA.CFrame = a
    RA.CFrame = b 
end
local larm = figure:FindFirstChild("Left Arm")
local rarm = figure:FindFirstChild("Right Arm")
function onReplied(player,pick)
    local stats = player:findFirstChild("leaderstats") 
    local cur = stats:findFirstChild(currency) 
    if (cur.Parent == nil) then
        return
    end
    local c = d
    for i = 1,#c do
        if (pick.Name == c[i].Name) then
            if (cur.Value >= pick.Cost.Value) then 
                cur.Value = cur.Value - c[i].Cost.Value 
                if (keepOnDeath == true) then
                    arm_GiveEffect(larm,rarm)
                    local item1 = items:FindFirstChild(c[i].ItemName.Value)
                    local item2 = items:FindFirstChild(c[i].ItemName.Value)
                    item1:clone().Parent = player.StarterGear
                    item2:clone().Parent = player.Backpack
                    print("Item safe")
                else
                    arm_GiveEffect(larm,rarm)
                    local item = items:FindFirstChild(c[i].ItemName.Value)
                    item:clone().Parent = player.Backpack
                end
            else
                print("Not enough ",currency)
            end
        end 
    end
end
dialog.DialogChoiceSelected:connect(onReplied)

2 answers

Log in to vote
0
Answered by
Xoqex 75
10 years ago

I'm not very advanced at all, I'm just learning but it could be one of these: Did you make sure to call the functions? or it could be you don't have enough ends/Too many ends.

Ad
Log in to vote
-1
Answered by 10 years ago

You probably don't have a "currency" script in your Workspace. If not, it's probably an error with your script.

0
Mk EmperorF 0 — 10y

Answer this question