#need help to figure out whats wrong

7 messages · Page 1 of 1 (latest)

safe fog
#

im trying to make a points left to limit the amount of points a player can put into a stat and roblox studio isnt telling me whats wrong

local textButton = script.Parent
local statvalue = game.Players.LocalPlayer.PlayerGui.ScreenGui.MenuFrame.StrFrame.Stat

_G.PointsLeft = game.Players.LocalPlayer.PlayerGui.ScreenGui.MenuFrame.PointsLeft.Text


_G.spd = 0
_G.str = 0
_G.stattotal = 100 - _G.str - _G.spd

local function onActivated()

    if _G.stattotal < 1 then
        _G.str = _G.str
    elseif _G.stattotal > 1 then
        _G.str = _G.str + 1
        statvalue = _G.str
    end
    
    _G.PointsLeft = _G.stattotal
    
end


textButton.Activated:Connect(onActivated)```
compact mist
#

Why do u even use _G?

safe fog
#

i find it simpler to use imo

compact mist
#

but not efficient and gonna gives a lot of problems in future

safe fog
#

if theres a better way then lmk

compact mist
#

modules

safe fog
#

lowk how do modules work cause i havent been coding for very long