01 | local particleem = workspace:WaitForChild( "Igniterone" ).igniteparts.emiter.ParticleEmitter |
02 | local clickdet = script.Parent.ClickDetector |
03 | local button = script.Parent |
04 | local status = false |
05 | local sound = workspace:WaitForChild( "Igniterone" ).igniteparts.Sound |
06 | local energyvtext = workspace:WaitForChild( "EnergyPanel" ).Part.SurfaceGui.energyvalue |
07 | local energyvalue = tonumber (energyvtext.Text) |
08 | print (energyvalue) |
09 | local newval |
10 | local newvalstring |
11 | clickdet.MouseClick:Connect( function () |
12 | if status = = false then |
13 | particleem.Enabled = true |
14 | button.BrickColor = BrickColor.new( "Really red" ) |
15 | sound.Playing = true |
Everything here is working except that it changes the value of energyvtext, i want it to add 25 to it and remove 25 but it doesn't, it just changes, not adds or removes.
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?
Bit of a logic problem you got going here, an easy fix I think. You're setting newval
to energyvalue -25
. Instead, you should set the newVal to newVal = newVal -25
.
If you actually want energy value to change, then you should do something like this:
newVal = energyValue -25; energyValue = newVal
Heres what it looks like in your own script:
01 | clickdet.MouseClick:Connect( function () |
02 | if status = = false then |
03 | particleem.Enabled = true |
04 | button.BrickColor = BrickColor.new( "Really red" ) |
05 | sound.Playing = true |
06 | newval = energyvalue + 24 |
07 | energyvalue = newval |
08 | newvalstring = tostring (newval) |
09 | energyvtext.Text = newvalstring |
10 | status = true |
11 | elseif status = = true then |
12 | particleem.Enabled = false |
13 | button.BrickColor = BrickColor.new( "Lime green" ) |
14 | sound.Playing = false |
15 | newval = energyvalue - 25 |