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

this button, "on clicked" script is not functioning. elseif isn't working either?

Asked by 5 years ago

this script is a button to confirm a purchase.

however, when i run the code and try it out, it doesn't seem to work. (this is a localscript)

01button = script.Parent
02local Player = game.Players.LocalPlayer
03 
04local Tics = Player:WaitForChild("XPCASHFOLDER").Tics
05local acquired = Player:WaitForChild("Brawlers").HitmanAcquired
06local Title = script.Parent.Parent.Title
07 
08button.MouseButton1Click:Connect(function(clicked)
09    if clicked and Tics.Value < 999 then
10    Tics.Value = Tics.Value - 1000
11    acquired.Value = true
12    script.Parent.Parent.Visible = false
13    elseif
14        clicked and Tics.Value > 999 then
15        Title.Text = "NOT ENOUGH"
View all 24 lines...

1 answer

Log in to vote
1
Answered by
sleazel 1287 Moderation Voter
5 years ago

I do not recall MouseButton1Click event passing any arguments, nor I can find anything on API reference. I have always used this event without any anyway and it was working fine. It may be your issue. Try this instead:

01button = script.Parent
02local Player = game.Players.LocalPlayer
03 
04local Tics = Player:WaitForChild("XPCASHFOLDER").Tics
05local acquired = Player:WaitForChild("Brawlers").HitmanAcquired
06local Title = script.Parent.Parent.Title
07 
08button.MouseButton1Click:Connect(function()
09 
10    if Tics.Value < 999 then
11        Tics.Value = Tics.Value - 1000
12        acquired.Value = true
13        script.Parent.Parent.Visible = false
14    elseif Tics.Value > 999 then
15        Title.Text = "NOT ENOUGH"
View all 24 lines...

Have a nice scripting session.

Ad

Answer this question