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

No guis in PlayerGui? Whats the reason behind this?

Asked by 6 years ago
Edited 6 years ago

hey, im trying to get the gui to change every time u buy something, it should say "Purchase Complete for $(cash)" but nothing happens. http://prntscr.com/kxkgz2 here is a sc of the error why are there no guis in PlayerGui? please help and actually answer my question

    --[[
        All configurations are located in the "Settings" Module script.
        Please don't edit this script unless you know what you're doing.
    --]]
    local Objects = {}
    local TeamColor = script.Parent.TeamColor.Value
    local Settings = require(script.Parent.Parent.Parent.Settings)
    local Money = script.Parent.CurrencyToCollect
    local Debris = game:GetService('Debris')
    local Stealing = Settings.StealSettings
    local CanSteal = true -- don't change or else you won't be able to steal currency

    script.Parent.Essentials.Spawn.TeamColor = TeamColor
    script.Parent.Essentials.Spawn.BrickColor = TeamColor

    function Sound(part,id)
        if part:FindFirstChild('Sound') then
            return
        else
            local Sound = Instance.new('Sound',part)
            Sound.SoundId = "rbxassetid://"..tostring(id)
            Sound:Play()
            delay(Sound.TimeLength, function()
                Sound:Destroy()
            end)
        end
    end

    --Parts that fall into the collector(s) get processed
    for i,v in pairs(script.Parent.Essentials:GetChildren()) do
        if v.Name == "PartCollector" then
            v.Touched:connect(function(Part)
                wait(0.1)
                Part.Transparency = 0.1
                wait(0.1)
                Part.Transparency = 0.2
                wait(0.1)
                Part.Transparency = 0.3
                wait(0.1)
                Part.Transparency = 0.4
                wait(0.1)
                Part.Transparency = 0.5
                wait(0.1)
                Part.Transparency = 0.6
                wait(0.1)
                Part.Transparency = 0.7
                wait(0.1)
                Part.Transparency = 0.8
                wait(0.1)
                Part.Transparency = 0.9
                wait(0.1)
                Part.Transparency = 1
                if Part:FindFirstChild('Cash') then
                    Money.Value = Money.Value + Part.Cash.Value
                    Debris:AddItem(Part,0.01)
                end
            end)
        end
    end

    --Player Touched Collector processor
    deb = false
    script.Parent.Essentials.Giver.Touched:connect(function(hit)
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player ~= nil then
            if script.Parent.Owner.Value == player then
                if hit.Parent:FindFirstChild("Humanoid") then
                    if hit.Parent.Humanoid.Health > 0 then
                        if deb == false then
                            deb = true
                            script.Parent.Essentials.Giver.BrickColor = BrickColor.new("Bright red")
                            local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
                            if Stats ~= nil then 
                            Sound(script.Parent.Essentials, Settings.Sounds.Collect)
                            Stats.Value = Stats.Value + Money.Value
                            Money.Value = 0
                            wait(1)
                            script.Parent.Essentials.Giver.BrickColor = BrickColor.new("Sea green")
                            deb = false
                            end
                        end
                    end
                end
            elseif Stealing.Stealing then -- if player isn't owner and stealing is on
                if CanSteal == true then
                    CanSteal = false
                    delay(Stealing.PlayerProtection, function()
                        CanSteal = true
                    end)
                    if hit.Parent:FindFirstChild("Humanoid") then
                        if hit.Parent.Humanoid.Health > 0 then
                            local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
                            if Stats ~= nil then
                                local Difference = math.floor(Money.Value * Stealing.StealPrecent)
                                Sound(script.Parent.Essentials, Settings.Sounds.Collect)
                                Stats.Value = Stats.Value + Difference
                                Money.Value = Money.Value - Difference
                            end
                        end
                    end
                else
                    Sound(script.Parent.Essentials, Settings.Sounds.Error)
                end
            end
        end
    end)

    script.Parent:WaitForChild("Buttons")
    for i,v in pairs(script.Parent.Buttons:GetChildren()) do
        spawn(function()
        if v:FindFirstChild("Head") then

            local ThingMade = script.Parent.Purchases:WaitForChild(v.Object.Value)
            if ThingMade ~= nil then
                Objects[ThingMade.Name] = ThingMade:Clone()
                ThingMade:Destroy()
            else
                --//Button doesn't have object, remove it
                error('Object missing for button: '..v.Name..', button has been removed')
                v.Head.CanCollide = false
                v.Head.Transparency = 1
            end

            if v:FindFirstChild("Dependency") then --// if button needs something unlocked before it pops up
                v.Head.CanCollide = false
                v.Head.Transparency = 1
                coroutine.resume(coroutine.create(function()
                    if script.Parent.PurchasedObjects:WaitForChild(v.Dependency.Value) then
                        if Settings['ButtonsFadeIn'] then
                            for i=1,20 do
                                wait(Settings['FadeInTime']/20)
                                v.Head.Transparency = v.Head.Transparency - 0.05
                            end
                        end
                        v.Head.CanCollide = true
                        v.Head.Transparency = 0
                    end
                end))
            end

            v.Head.Touched:connect(function(hit)
                local player = game.Players:GetPlayerFromCharacter(hit.Parent)
                if v.Head.CanCollide == true then
                    if player ~= nil then
                        if script.Parent.Owner.Value == player then
                            if hit.Parent:FindFirstChild("Humanoid") then
                                if hit.Parent.Humanoid.Health > 0 then
                                    local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
                                    if PlayerStats ~= nil then
                                        if (v:FindFirstChild('Gamepass')) and (v.Gamepass.Value >= 1) then
                                            if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,v.Gamepass.Value) then
                                                Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
                                            else
                                                game:GetService('MarketplaceService'):PromptPurchase(player,v.Gamepass.Value)
                                            end
                                        elseif (v:FindFirstChild('DevProduct')) and (v.DevProduct.Value >= 1) then
                                            game:GetService('MarketplaceService'):PromptProductPurchase(player,v.DevProduct.Value)
                                        elseif PlayerStats.Value >= v.Price.Value then
                                            Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
                                            Sound(v, Settings.Sounds.Purchase)
                                        else
                                            Sound(v, Settings.Sounds.ErrorBuy)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end)
            end
        end)
    end

    function Purchase(tbl)
        local cost = tbl[1]
        local item = tbl[2]
        local stats = tbl[3]
        stats.Value = stats.Value - cost
        Objects[item.Object.Value].Parent = script.Parent.PurchasedObjects
        if Settings['ButtonsFadeOut'] then
            item.Head.CanCollide = false
            coroutine.resume(coroutine.create(function()
                for i=1,20 do
                    wait(Settings['FadeOutTime']/20)
                    item.Head.Transparency = item.Head.Transparency + 0.05
                    local gui = game.Players.LocalPlayer:WaitForChild('PlayerGui').StatusGui.Frame.TextLabel
                    gui.Text = "Purchase Completed for $"..cost
                end
            end))
        else
            item.Head.CanCollide = false
            item.Head.Transparency = 1
        end
    end

    function Create(tab)
        local x = Instance.new('Model')
        Instance.new('NumberValue',x).Value = tab[1]
        x.Value.Name = "Cost"
        Instance.new('ObjectValue',x).Value = tab[2]
        x.Value.Name = "Button"
        local Obj = Instance.new('ObjectValue',x)
        Obj.Name = "Stats"
        Obj.Value = tab[3]
        x.Parent = script.Parent.BuyObject
    end

    --// This was very rushed and is inefficent; if you plan on making something like this don't use a child added listener.
    script.Parent:WaitForChild('BuyObject').ChildAdded:connect(function(child)
        local tab = {}
        tab[1] = child.Cost.Value
        tab[2] = child.Button.Value
        tab[3] = child.Stats.Value
        Purchase(tab)
        wait(10)
        child:Destroy()
    end)
0
isn't this a fm tycoon kit green271 635 — 6y
0
Also, NEVER do game.Players.LocalPlayer from the server, that doesn't work as the server doesn't know which person is the local player theking48989987 2147 — 6y
0
yes green, just making it better xD InfiniteWhileLoop 19 — 6y
0
what should i do king? what do i replace it with? InfiniteWhileLoop 19 — 6y
View all comments (13 more)
0
just dont do game.Players.LocalPlayer on the server, get it from somewhere else theking48989987 2147 — 6y
0
but where lmao InfiniteWhileLoop 19 — 6y
0
can we see your full scripts, so we can see what other way you can get the player theking48989987 2147 — 6y
0
ok, ill edit and post full InfiniteWhileLoop 19 — 6y
0
done king InfiniteWhileLoop 19 — 6y
0
The whole gamepass section needs to be updated as well, GP’s are no longer assets ABK2017 406 — 6y
0
Do you own the Dev Products? ABK2017 406 — 6y
0
the tranparency part, oh dear theking48989987 2147 — 6y
0
how would u fix that? InfiniteWhileLoop 19 — 6y
0
the gamepasses InfiniteWhileLoop 19 — 6y
0
“game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 1234567) then” ABK2017 406 — 6y
0
Everywhere you have PlayerOwnsAsset if it references a gamepass ABK2017 406 — 6y
0
dosent work InfiniteWhileLoop 19 — 6y

Answer this question