#energy goes to 0 after i sell but the popup still shows and doesnt give energy

1 messages · Page 1 of 1 (latest)

lone moth
#

server script placed inside the coin


            local reward=25
            
            if energy<capacity then
            player.leaderstats.energy.Value+=reward
            coin.Parent=game:GetService('ReplicatedStorage')
        else
fullpopup:FireClient(player)
            print('maximum energy has been reached!')
            end
            wait(2)
            coin.Parent=workspace```

local script placed inside screengui
```local fullpopup=script.Parent.fullPopUp
local popupevent=game:GetService('ReplicatedStorage').fullpopup
popupevent.OnClientEvent:Connect(function()
    fullpopup.Visible=true
end)```
#

energy goes to 0 after i sell but the popup still shows and doesnt give energy

cerulean flicker
# lone moth server script placed inside the coin ``` if hit.Parent:FindFirstChild('H...

there's no code to hide the popup.

Either make some button on the pop up to close it: (you do have to actually add the button as well, duh)

fullpopup.CloseButton.MouseButton1Click:Connect(function()
  fullpopup.Visible = false
end)

or just close it via some other event, i.e. you mention selling, you could also link such an event up to a similar functions.

#

Alternative would be to use something like task.delay to automatically close it after a set number of seconds have passed

lone moth
#

mb also ```local sell=script.Parent
sell.Activated:Connect(function()
sell.Parent.Visible=false

local plr=game.Players.LocalPlayer

local capacity=plr.leaderstats.capacity
local energy=plr.leaderstats.energy
local energycoins=plr.leaderstats.EnergyCoins

energycoins.Value+=energy.Value*10
energy.Value=0

if energy.Value==0 then
end

end)```

lone moth
cerulean flicker
lone moth
#

why??

cerulean flicker
#
  1. it won't replicate to the server, so the server doesn't see any changes happening
  2. if you network it in a way that the server does see it sell, then a player can easily add his own scripts to cheat in money
lone moth
cerulean flicker
#

The server still thinks that your energy is full

lone moth
#

ouch

#

can i just put a remote event on my sell button local script 4 that or would that be bad??

cerulean flicker
lone moth
#

thanks vro

#

ill try that

cerulean flicker
#

Also a hint. If you wish to see the values that the server sees, click this button. It will switch you between the client view and the server view

lone moth
#

thank u

#

man i love u it worked

lone moth
#

its not about this script but u r a smart fella

#
local char=player.Character
local torso = char:FindFirstChild("UpperTorso") or char:FindFirstChild("Torso")

local part=game:GetService('ReplicatedStorage').backPack:Clone()
part.Anchored=false
part.CanCollide=true
part.CFrame=torso.CFrame*CFrame.new(0,0,1.5)
part.Parent=char

local weld=Instance.new('WeldConstraint')
weld.Part0=torso
weld.Part1=part
weld.Parent=part
#

i made the backpack thing yinto a client script

#

i cant make it server side

#

oh nvm i got it