Hello forummers, Ive been making a button simulator and i was wondering how i could be able to make the part of the buttons turn neon in material when the players can afford to buy the buttons. Ive tried alot of things yet none of them worked.
this is my script (theres more in it):
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local EternityNum = require(Modules.EternityNum)
local StatModule = require(Modules.StatModule)
local Relics = require(Modules.Relics)
local ButtonFunctions = {}
function ButtonFunctions.GetStatFromName(Stat) -- finds statnumber from stat name
for i,v in StatModule do
if v.StatName == Stat then
return i
end
end
return nil
end
function ButtonFunctions.BuyButton(Player, Button, Stat)
local StatNumber = ButtonFunctions.GetStatFromName(Stat)
if StatNumber then
Button = tonumber(Button.Name)
local StatInfo = StatModule[StatNumber]
local BuyStat = StatModule[StatInfo.BuyStat]
local Bought = false
--// Can you afford the stat?
if BuyStat then -- one buy stat
local ConvertedStat,ConvertedCost = EternityNum.convert(Player.Data.Stats[BuyStat.StatName].Value), EternityNum.convert(StatInfo.Buttons[Button].Cost)
if EternityNum.meeq(ConvertedStat,ConvertedCost) then
Bought = true
end
end
if not Bought then return end
-- Resets
local StatsToReset = StatInfo.BuyStat
if not StatModule[StatInfo.BuyStat] then StatsToReset = StatsToReset[2] end -- buystat or 2nd buystat
for i = StatsToReset, 1, -1 do
Player.Data.Stats[StatModule[i].StatName].Value = StatModule[i].StartingValue
end
--// Find Stat Above
local StatAbove = {1,0,1}
if not StatInfo.MultiplyingStat then -- if MultiplyingStat is not Setup then the multiplier is the stat above
local StatInfoAbove = StatModule[StatNumber+1]
if StatInfoAbove then
StatAbove = EternityNum.add(StatAbove, EternityNum.convert(Player.Data.Stats[StatInfoAbove.StatName].Value)) -- StatAbove = 1 + howmuch u got
end
else
local MStat = StatInfo.MultiplyingStat
if StatModule[MStat] then -- normal
StatAbove = EternityNum.add(StatAbove, EternityNum.convert(Player.Data.Stats[StatModule[MStat].StatName].Value)) -- Multiplying = 1 + howmuch u got
end
end
--// Calculate the multipliers
local Gain = EternityNum.convert(StatInfo.Buttons[Button].Gain)
local Multiplier = EternityNum.mul(Gain, StatAbove)
local StatMultiplier = StatInfo.StatMultiplier(Player.Data)
if StatMultiplier ~= 1 then
Multiplier = EternityNum.mul(Multiplier, EternityNum.convert(StatMultiplier))
end
--// Add to values
local Addition = EternityNum.add(Multiplier, EternityNum.convert(Player.Data.Stats[Stat].Value)) -- Multiplier + CurrentStatValue
Player.Data.Stats[Stat].Value = EternityNum.toString(Addition)
Player.Data.PlayerData["Buttons Pressed"].Value += 1
--Player.Data.Stats.Tokens.Value += math.random(0.001,0.05) * (Player.Data.Upgrades.Tokens.Value * 1.25)
end
end
this is my buttons hirearchy:
keep in mind, i want the Forcefield object to be the one to turn neon