Hello, I’ve been trying to make it so that a GUI pops up every time a player gets money. Like what you see in many games as a “salary”. I’m using a tween for the pop up, and the tween seems to be working properly.
But… I can’t seem to get the GUI to be only on the local players end. Currently, the GUI is very inconsistent and randomly shows up when its time or doesn’t show at all. Many players hear the sound from other people’s ends too. And yes, I did make it so the GUI doesn’t reset on spawn, as you might see in my note in the code.
Previously to this code example, I made it so that a separate server script triggered a bool, and the local GUI would pick it up, but unfortunately everybody would see it playing, and they wouldn’t get the cash unless the time matched up with them.
Does anybody know what could be wrong with my code, or a potential sollution?
while wait(10) do
local player = script.Parent.Parent.Parent.Parent
local Currency = "X-Points"
local Income = 50
local TweenService = game:GetService("TweenService")
local UI = script.Parent
local StarterGui = game:GetService("StarterGui")
if player.leaderstats:findFirstChild(Currency) ~= nil then
local cash = player.leaderstats:findFirstChild(Currency)
cash.Value = cash.Value + Income
UI.Visible = true
StarterGui.PlusCashGui.CashAmount["Coins ka-ching"]:Play()
UI:TweenPosition(UDim2.new(.784, 0,0.942, 0), "Out", "Back")
wait(5)
UI.Visible = false
StarterGui.PlusCashGui.CashAmount.Pop:Play()
wait(1)
end
end
-- DO NOT enable "Reset on spawn", this causes the countdown to restart everytime the player respawns
Thanks everybody!