#variable over multiple localscripts

10 messages · Page 1 of 1 (latest)

ruby kiln
#

hi, I want my currency to exist over multiple localscripts, so they share the same value, but I have no idea how to do that

#

it's a script to increase the value of a currency by 1 or decrease it by 1

#

the blue button increases it, the red button decreases it

jolly gulch
#

Easiest solution to your problem

-- place the script under your ScreenGui
local ScreenGui = script.Parent
local whitestuff = 0
local function AddClicked()
  whitestuff += 1 
  ScreenGui.Label.Text = "yourtext "..whitestuff
end
local function SubtractClicked()
  whitestuff -= 1
  ScreenGui.Label.Text = "yourtext "..whitestuff
end
-- rename the blue button which gives 1 to "GiveButton"
-- rename the red button which subtracts 1 to "SubtractButton"
screenGui["GiveButton"].MouseButton1Click:Connect(AddClicked)
screenGui["SubtractButton"].MouseButton1Click:Connect(SubtractClicked)
#

I'd recommend not using local whitestuff = 0 at all and making a leaderstat Whitestuff for each player if you want every other player to have a different currency amount

#

or give players an IntValue attribute Whitestuf and add to that every time

ruby kiln
#

do you know how to make the leaderstat or is it already in the code?

jolly gulch
#

if you want the value to be global and only 1 for the whole server then create an IntValue and put it in ReplicatedStorage and control it with that