Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Egg popup that works until i sell the eggs (Simulator game) ?

Asked by 4 years ago
Edited 4 years ago

I made it so that it pops up when you pick up a egg or if you get coins. When i pick up the eggs the popup works fine, but then when i go and sell my eggs to coins and i go back to the eggs and try to pick them up the popup doesn't show on screen. Then randomly it starts working when you pickup af lot of eggs.

Gif that show how it looks like: https://gyazo.com/ade66de5e3beb2264e2c392b428cd326

The script for the popup

wait()
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
if leaderstats then
    local Eggs = leaderstats:FindFirstChild("Eggs")
    if Eggs then
        local lastvalue = Eggs.Value
        Eggs.Changed:connect(function()
            if Eggs.Value >= lastvalue then
                local NewUi = script.TextLabel:Clone()
                NewUi.Parent = script.Parent
                NewUi.Visible = true
                NewUi.Text = "????"..Eggs.Value - lastvalue
                NewUi.Position = UDim2.new(0.477,0,0.460,0)
                NewUi:TweenPosition(UDim2.new(0.066,0,0.405,0),"Out",0.2,true)
                wait(0.95)
                NewUi:Destroy()
                lastvalue = Eggs.Value
            end
        end)
    end
end

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

My guess is on line 7, you set the lastvalue to however many eggs you last had, and the gui won't show up unless the new egg value is greater than lastvalue.

I'm more of a visual explainer, so here.

What's happening is

before selling: lastvalue = 10 (just an example)

and after selling, lastvalue is still 10 and Eggs.Value is 0.

Now it's checking if the egg value is greater than 10. If it's not, it won't show up. If it is, it'll show up in a bunch.

after selling: lastvalue = 10 | Eggs.Value = 0

So it won't change unless Eggs.Value (0) is > lastvalue (10)


This is just a guess, try it out.

Remove line 7 (local lastvalue = Eggs.Value) and Remove line 9 (if Eggs.Value >= lastvalue then) and Remove line 19 (end)


Hopefully this makes sense. If it doesn't just do what I said in the second section and I'm 75% sure this would work.

~killerbrenden

0
Thank you. Had to keep line 7 tho. asbjornbonde 32 — 4y
0
Alright, no problem! Glad to help. If this worked, select it as an answer so everyone else knows this question has been solved. killerbrenden 1537 — 4y
Ad

Answer this question