#TextLabel Does not want to Update

1 messages · Page 1 of 1 (latest)

tired ice
#

Can anyone help

valid junco
tired ice
#

my bad i was waiting for response

#

so here is my code


local player = game.Players.LocalPlayer
local Button = script.Parent
local Mouse = player:GetMouse()
local Rep = game:GetService("ReplicatedStorage")
local Event = Rep:FindFirstChild("TelPortEvent")
local Sound = Button.Goku
local BodyScreen = player.PlayerGui:FindFirstChild("BodyScreen")
local EnergyFrame = BodyScreen:FindFirstChild("EnergyFrame")

Button.MouseButton1Click:Connect(function()
    if Button.Text == "TelePort" then
        Button.Text = "Stop"
        wait(0.1)

        
        Mouse.Button1Down:Connect(function()
            if Mouse.Target and Mouse.Target:IsA("BasePart") then
                local hit = Mouse.Hit.Position
                local Value = tonumber(EnergyFrame.MinNum.Text) 

                
                print("Current Energy Value: " .. tostring(Value))

                
                if Value then
                    Sound:Play()

                    
                    Value = Value - 100

                    
                    if Value < 0 then
                        Value = 0
                    end

                    
                    EnergyFrame.MinNum.Text = tostring(Value)

                    
                    print("Updated Energy Value: " .. tostring(Value))

                    
                    Event:FireServer(hit)
                else
                    warn("Invalid value in MinNum text!")
                end
            end
        end)
    elseif Button.Text == "Stop" then
        Button.Text = "TelePort"
    end
end)

#

but the EnergyFrame.MinNum.Text = tostring(Value)
i does not want to Update as wanted

valid junco
#

I'm not 100% sure I understand.

Is it setting it to something you don't want? Is it not setting it at all?

languid smelt
#
Button.MouseButton1Click:Connect(function()
    if Button.Text == "TelePort" then
        Button.Text = "Stop"
        wait(0.1)

        
        Mouse.Button1Down:Connect(function()```
that's not how events work, you are connecting to mouse.button1down every time the textbutton is clicked. events are not conditions, they are not magic waits, they are events. they run when the event happens, not when you connect it.
tired ice
tired ice
languid smelt
tired ice
#

the TextLabel(MinNum

#

so when the Button is Pressed

#

then the mouse should activate and whenever the player clicks somewhere he should Teleport to it

#

which works perfect

#

but while he Teleport it will Cost him an Energy which is -100

#

and The TextLabel (MinNum) its text is right now 200 it should be able to decrease when the Mouse is Pressed and everything works fine it also prints everything that needs to be printed and it does print that it changed but when i look at the TextLabel i still see the same number which is 200

#

while it should be decreased to 100

languid smelt
#

i suspect you're changing it on both the server and client

#

coz if its getting to this Event:FireServer(hit) then i would expect everything else to be fine, aside from the already mentioned connecting events multiple times

tired ice
languid smelt
#

could also be the path is wrong, duplicates with the same name, etc

tired ice
#

wait let me check rq

tired ice
#

@languid smelt so i think i found the proble

#

its my guis that are broken is what i think

#

when playing the game i runned this command: game.Players.LocalPlayer.PlayerGui.BodyScreen.EnergyFrame.MinNum.Text = "100"

#

and the Text did not want to change at all and i get no errors or anything

languid smelt
#

yep so look through those folders in explorer and see if everything is in the right place

tired ice
#

nvm i found it now

#

another script was changing it instant back to 200 idk why

languid smelt
tired ice
#

Can you maybe help its a big script and i have no idea where im going wrong with this one

languid smelt
#

i dont do that kind of thing without payment. small help threads are fine on occasion but i aint doing your whole project for you

tired ice
#

oh ok no problem but thanks for the help tho

languid smelt
#

you're still connecting the event multiple times though, each time the textbutton is pressed

#

but dw i'm sure you'll figure that out sooner or later ;p

tired ice
#

i will change that