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

Why is my MouseButton1Click not firing? [SOLVED]

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)

6 comments

0

Is the script enabled? Try printing before the click and after the click

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

0

is the script and the text button archivable?

0

You cant change intvalues from local scripts as they are server side, use remote events to do this.

0

yes, both are archivable

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

2 answers

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)

3 comments

0

Please provide an explanation so people can learn, just posting code is not good enough.

0

Uh...I provided the explanation to @SpelunkyGaming on the community chat

0

You need to say in your question that you did that.

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)

3 comments

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! :)

0

I dunno how to edit the question ;w;

0

Nvm, I got it

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