I am trying to tween a GUI each time you kill an NPC that shows the money and exp you get and then it zooms across the screen to go into the correct gui that shows your money and exp. I have it working with the following script and I have the original GUI in StarterGui, but the problem is that if I kill another enemy right after the first (while the first gui is still on the screen) it ignores the 2nd gui. How can I fix this? I have moved things around, but the only other thing I can think of is putting the gui in replicated storage, but I can’t see how that would work any better. Thanks.
local hum = script.Parent:WaitForChild("Humanoid")
hum.Died:Connect(function()
local tag = hum:FindFirstChild("creator")
if tag then
local killer = tag.Value
if killer then
killer.leaderstats.Cash.Value = killer.leaderstats.Cash.Value + 50 + (killer.leaderstats.Rebirths.Value*50/10)
killer.leaderstats.Experience.Value = killer.leaderstats.Experience.Value + 10 + (killer.leaderstats.Rebirths.Value*10/10)
local score = killer.PlayerGui.Pickups:Clone()
score.Name = "Score"
score.Parent = killer.PlayerGui
killer.PlayerGui.Score.Frame1.Cash.Text = "$"..(50 + (killer.leaderstats.Rebirths.Value*50/10))
killer.PlayerGui.Score.Frame2.Exp.Text = 10 + (killer.leaderstats.Rebirths.Value*10/10).." EXP"
killer.PlayerGui.Score.Enabled = true
killer.PlayerGui.Score.Frame1.Cash:TweenSize(UDim2.new(1,0,1,0),.5)
killer.PlayerGui.Score.Frame2.Exp:TweenSize(UDim2.new(1,0,1,0),.5)
wait(1)
killer.PlayerGui.Score.Frame1:TweenPosition(UDim2.new(0.3,0,0.1,0),Enum.EasingDirection.In,Enum.EasingStyle.Elastic,2)
killer.PlayerGui.Score.Frame2:TweenPosition(UDim2.new(0.5,0,0,0),Enum.EasingDirection.In,Enum.EasingStyle.Elastic,1.9)
wait(2)
killer.PlayerGui.Score:Destroy()
end
end
end)