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

How would I put a cloned frame into a certain players PlayerGui?

Asked by 2 years ago
Edited 2 years ago

I've been trying to put a cloned frame inside of a certain player's PlayerGui for some time now but I don't know exactly how to do that as every time I've tried it won't work.

---Server Side(Heavily connected to the client-side.)

--###----------[[SERVICES]]----------###--
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--###----------[[KILLHANDLER]]----------###--
Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(character)
        character.Humanoid.Died:Connect(function()
            print("Player Killed")
            local Humanoid = character:WaitForChild("Humanoid")

            ---PlayerHealth
            local Health = Humanoid.Health
            ---Script
            local tag = character.Humanoid:FindFirstChild("creator")
            if tag ~= nil then
                local Killer = tag.Value
                Killer.leaderstats.Kills.Value += 1
                local Playername = Player.Name
                if Health >= 36 then
                    Player:FindFirstChild("leaderstats").OtherStats.Exp.Value += 50
                    local KillStatsClone1 = ReplicatedStorage:FindFirstChild("UI").KillPopUp:Clone()
                    local Victim = Player
                    ReplicatedStorage:FindFirstChild("Events").KillStatsUI1:FireClient(Killer, KillStatsClone1, Victim)
                elseif Health <= 35 then
                    Player:FindFirstChild("leaderstats").OtherStats.Exp.Value += 75
                    local KillStatsClone2 = ReplicatedStorage:FindFirstChild("UI").KillPopUp:Clone()
                    local Victim = Player
                    ReplicatedStorage:FindFirstChild("Events").KillStatsUI1:FireClient(Killer, KillStatsClone2, Victim)
                end
                ReplicatedStorage:FindFirstChild("Events").EXPEvent:FireClient()
                print("Kill, and EXP Added!")
            end
        end)
    end)
end)

---Client Side(Main Problem)

--###----------[[SERVICES]]----------###--
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--###----------[[PLAYER]]----------###--
local Player = Players.LocalPlayer
local Character = Player.Character
local leaderstats = Player:WaitForChild("leaderstats")
local OtherStats = leaderstats:WaitForChild("OtherStats")
local Humanoid = Character:WaitForChild("Humanoid")
local Health = Humanoid.Health
---UIComponents
local KillPopUp = ReplicatedStorage.UI["KillPopUp"]
local Skull = KillPopUp["Skull"]
local KillEXP = KillPopUp["KillEXP"]
local PlayerName = KillPopUp["PlayerName"]
local CloseExp = KillPopUp["CloseExp"]
local CloseCall = KillPopUp["CloseCall"]
local Total = KillPopUp["Total"]

---Tween
local Info = {

    Info1 = TweenInfo.new(1),

    Info2 = TweenInfo.new(2),

    Info3 = TweenInfo.new(3),

    Info4 = TweenInfo.new(4),

    Info5 = TweenInfo.new(5),

    Info6 = TweenInfo.new(6)

}
local Tweens = {

    TweenTrue = {

        SkullTweenTrue = game:GetService("TweenService"):Create(Skull,Info.Info1,{ImageTransparency=0}),
        PlayerNameTweenTrue = game:GetService("TweenService"):Create(PlayerName,Info.Info2,{TextTransparency=0}),
        KillEXPTweenTrue = game:GetService("TweenService"):Create(KillEXP,Info.Info3,{TextTransparency=0}),
        CloseExpTweenTrue = game:GetService("TweenService"):Create(CloseExp,Info.Info4,{TextTransparency=0}),
        CloseCallTweenTrue = game:GetService("TweenService"):Create(CloseCall,Info.Info5,{TextTransparency=0}),
        TotalTweenTrue = game:GetService("TweenService"):Create(Total,Info.Info6,{TextTransparency=0}),

    },

    TweenFalse = {

        SkullTweenFalse = game:GetService("TweenService"):Create(Skull,Info.Info1,{ImageTransparency=1}),
        PlayerNameTweenFalse = game:GetService("TweenService"):Create(PlayerName,Info.Info2,{TextTransparency=1}),
        KillEXPTweenFalse = game:GetService("TweenService"):Create(KillEXP,Info.Info3,{TextTransparency=1}),
        CloseExpTweenFalse = game:GetService("TweenService"):Create(CloseExp,Info.Info4,{TextTransparency=1}),
        CloseCallTweenFalse = game:GetService("TweenService"):Create(CloseCall,Info.Info5,{TextTransparency=1}),
        TotalTweenFalse = game:GetService("TweenService"):Create(Total,Info.Info6,{TextTransparency=1}),

    }

}
---Script
ReplicatedStorage:FindFirstChild("Events").KillStatsUI1.OnClientEvent:Connect(function(Killer, KillStatsClone1, Victim)
    local KillerPlayer = Players:FindFirstChild(Killer)
    KillStatsClone1.Parent = KillerPlayer.PlayerGui.MenuHandler.MainGui
    KillStatsClone1.Total.Text = 50
    KillStatsClone1.PlayerName.Text = Victim.Name
    KillStatsClone1.CloseCall:Destroy()
    KillStatsClone1.CloseExp:Destroy()
    Tweens.TweenTrue.SkullTweenTrue:Play()
    Tweens.TweenTrue.PlayerNameTweenTrue:Play()
    Tweens.TweenTrue.KillEXPTweenTrue:Play()
    Tweens.TweenTrue.TotalTweenTrue:Play()
    wait(2.5)
    Tweens.TweenFalse.SkullTweenFalse:Play()
    Tweens.TweenFalse.PlayerNameTweenFalse:Play()
    Tweens.TweenFalse.KillEXPTweenFalse:Play()
    Tweens.TweenFalse.TotalTweenFalse:Play()
end)
ReplicatedStorage:FindFirstChild("Events").KillStatsUI2.OnClientEvent:Connect(function(Killer, KillStatsClone2, Victim)
    local KillerPlayer = Players:FindFirstChild(Killer)
    KillStatsClone2.Parent = KillerPlayer.PlayerGui.MenuHandler.MainGui
    KillStatsClone2.Total.Text = 75
    Tweens.TweenTrue.SkullTweenTrue:Play()
    Tweens.TweenTrue.PlayerNameTweenTrue:Play()
    Tweens.TweenTrue.KillEXPTweenTrue:Play()
    Tweens.TweenTrue.TotalTweenTrue:Play()
    Tweens.TweenTrue.CloseExpTweenTrue:Play()
    Tweens.TweenTrue.CloseCallTweenTrue:Play()
    wait(2.5)
    Tweens.TweenFalse.CloseExpTweenFalse:Play()
    Tweens.TweenFalse.CloseCallTweenFalse:Play()
    Tweens.TweenFalse.SkullTweenFalse:Play()
    Tweens.TweenFalse.PlayerNameTweenFalse:Play()
    Tweens.TweenFalse.KillEXPTweenFalse:Play()
    Tweens.TweenFalse.TotalTweenFalse:Play()
end)

1 answer

Log in to vote
0
Answered by 2 years ago

In the future, please don’t paste all of the code unless all of the code is relevant. It makes it hard for people to see the issue since we’re now sifting through 200+ lines of code.

So, just putting a frame into a playerGUI?

Frame.Parent = player.PlayerGui.ScreenGui should work. If it doesn’t, there’s an issue somewhere else.

0
and if it didn't work `player.PlayerGui:WaitForChild('ScreenGui')` zeyadtota3 7 — 2y
0
I tried this after fixing a bit of errors for the server-side that prevented it from working the way I wanted(so yes all the code I provided was relevant, and was all connected to the exact issue) I get the error "Players.Player1.PlayerGuI.MenuHandler.KillStats:60: attempt to index nil with 'PlayerGui'" vincentthecat1 199 — 2y
Ad

Answer this question