I am making a game that parodies how simulators are like. currently i am making a gui that shows everytime a stat increases (e.g coins)
this is my UIScript:
local plr = game.Players.LocalPlayer local lstats = plr:WaitForChild("leaderstats") local RpS = game:GetService("ReplicatedStorage") local maths = require(RpS:WaitForChild("GameModules"):WaitForChild("ShortenNumber")) local TS = game:GetService("TweenService") for i,v in ipairs(script.Parent:GetDescendants()) do if v.Name == "Fat" then v.Text = "Fat: "..maths:Abb(lstats:WaitForChild("Fat").Value) -- yes this is a eating sim xd lstats:WaitForChild("Fat"):GetPropertyChangedSignal("Value"):Connect(function() v.Text = "Fat: "..maths:Abb(lstats:WaitForChild("Fat").Value) end) elseif v.Name == "Coins" then v.Text = "Coins: "..maths:Abb(lstats:WaitForChild("Coins").Value) lstats:WaitForChild("Coins"):GetPropertyChangedSignal("Value"):Connect(function() v.Text = "Coins: "..maths:Abb(lstats:WaitForChild("Coins").Value) end) elseif v.Name == "Rebirths" then v.Text = "Rebirths: "..maths:Abb(lstats:WaitForChild("Rebirths").Value) lstats:WaitForChild("Rebirths"):GetPropertyChangedSignal("Value"):Connect(function() v.Text = "Rebirths: "..maths:Abb(lstats:WaitForChild("Rebirths").Value) end) end end RpS:WaitForChild("GameRemotes"):WaitForChild("Client"):WaitForChild("StatAdd").OnClientEvent:Connect(function(p1, p2) -- this is the function that errored local StatAddUI = RpS:WaitForChild("GameUIs"):WaitForChild("StatAdd"):Clone() StatAddUI.Parent = plr:WaitForChild("PlayerGui"):WaitForChild("PlayerMain") local stat_to_change = StatAddUI:WaitForChild("Stat") local amount = StatAddUI:WaitForChild("Amount") StatAddUI.Position = UDim2.new(math.random(0.125, 0.875), 0, math.random(0.125, 0.875), 0) -- didn't work but no error stat_to_change = p1 -- didn't work but no error amount = tostring(p2) -- didn't work but no error local TweenInf = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut) local Goal = {TextTransparency = 1} local Tween1 = TS:Create(stat_to_change, TweenInf, Goal) local Tween2 = TS:Create(amount, TweenInf, Goal) Tween1:Play() -- errored Tween2:Play() -- errored delay(1, function() StatAddUI:Destroy() end) end) RpS:WaitForChild("GameRemotes"):WaitForChild("Client"):WaitForChild("Buy").OnClientEvent:Connect(function() local ShopUI = script.Parent:WaitForChild("Shop") -- self explanatory local TweenInf = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut) local Goal = {Position = UDim2.new(0.5, 0, 0.5, 0)} local Tween = TS:Create(ShopUI, TweenInf, Goal) ShopUI:SetAttribute("Open", true) Tween:Play() end)
Problems:
it doesn't show the stat that changed, nor does it show how much the stat changed (didn't give an error)
it doesn't fade away like i intended to (gave an error: Unable to cast value to object)
What I have tried:
local TweenInf = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut) local Goal = {TextTransparency = 1} local Tween1 = TS:Create(stat_to_change, TweenInf, Goal) local Tween2 = TS:Create(amount, TweenInf, Goal) Tween1:Play() Tween2:Play()
to
while stat_to_change.TextTransparency < 1 do stat_to_change.TextTransparency += 0.1 amount.TextTransparency += 0.1 game:GetService("RunService").Heartbeat:Wait() --basically wait() but more consistent ig end
Extra info: 1. yes this is done in a local script after all it is a UI script :v 2. Picture of explorer window: here