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

Why is my MouseButton1Click not firing? [SOLVED]

Asked by 3 years ago
Edited 3 years ago

No errors, no prints, it just doesn't seem to run, LocalScript inside of a TextButton

local sdv = script.Parent.StarterDropperValue
local sdl = script.Parent.Parent.StarterDropperLabel
local mv = script.Parent.Parent.Parent.MoneyFrame.MoneyValue
local ml = script.Parent.Parent.Parent.MoneyFrame.MoneyLabel
local price = 10

script.Parent.MouseButton1Click:Connect(function()
    if mv.Value >= price then
        mv.Value = mv.Value - price
        ml.Text = "$" .. mv.Value
        sdv.Value = sdv.Value + 1
        price = price * 1.1
        script.Parent.Text = "Buy: $" .. price
        sdl.Text = sdl.Text + 1
    else
        script.Parent.Text = "Error"
        wait(0.5)
        script.Parent.Text = "Buy: $" .. price
    end
end)
0
Is the script enabled? Try printing before the click and after the click iOwn_You 543 — 3y
0
the script is enabled, and we tried printing before the if statement, and nothing happened, printing before the function, interestingly enough also doesn't print anything SpelunkyGaming 34 — 3y
0
is the script and the text button archivable? AlexTheCreator 461 — 3y
0
You cant change intvalues from local scripts as they are server side, use remote events to do this. WideSteal321 773 — 3y
View all comments (2 more)
0
yes, both are archivable SpelunkyGaming 34 — 3y
0
and as I said earlier in chat, i had a different local script using mousebutton1click that works flawlessly and does correctly edit the intvalues SpelunkyGaming 34 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
local sdv = script.Parent.StarterDropperValue
local sdl = script.Parent.Parent.StarterDropperLabel
local mv = script.Parent.Parent.Parent.MoneyFrame.MoneyValue
local ml = script.Parent.Parent.Parent.MoneyFrame.MoneyLabel
local price = 10
local something = script.Parent.Parent.StarterDropperLabel.Value

ml.Text = something

script.Parent.MouseButton1Click:Connect(function()
    if mv.Value >= price then
    ml.Text = something
        mv.Value = mv.Value - price
        ml.Text = "$" .. mv.Value
        sdv.Value = sdv.Value + 1
        price = price * 1.1
        script.Parent.Text = "Buy: $" .. price
        something.Value = something.Value + 1
    else
        script.Parent.Text = "Error"
        wait(0.5)
        script.Parent.Text = "Buy: $" .. price
    end
end)
0
Please provide an explanation so people can learn, just posting code is not good enough. WideSteal321 773 — 3y
0
Uh...I provided the explanation to @SpelunkyGaming on the community chat rushknight 17 — 3y
0
You need to say in your question that you did that. WideSteal321 773 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Somehow fixed, idk how but I'll take it lol.

local sdv = script.Parent.Parent.StarterDropperButton.StarterDropperValue
local sdl = script.Parent.Parent.StarterDropperLabel
local mv = script.Parent.Parent.Parent.MoneyFrame.MoneyValue
local ml = script.Parent.Parent.Parent.MoneyFrame.MoneyLabel
local price = 10

script.Parent.MouseButton1Click:Connect(function()
    if mv.Value >= price then
        mv.Value = mv.Value - price
        ml.Text = "$" .. mv.Value
        sdv.Value = sdv.Value + 1
        price = price * 1.1
        script.Parent.Text = "Buy: $" .. price
        sdl.Text = sdl.Text + 1
    else
        script.Parent.Text = "Error"
        wait(0.5)
        script.Parent.Text = "Buy: $" .. price
    end
end)
0
Please put something like [ SOLVED ] in the title so people dont try and answer, you don't have to but it would be great! :) WideSteal321 773 — 3y
0
I dunno how to edit the question ;w; SpelunkyGaming 34 — 3y
0
Nvm, I got it SpelunkyGaming 34 — 3y

Answer this question