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

[SOLVED] Admin Giver only works once, when player spawns. Why won`t it work when they respawn?

Asked by
Yuuwa0519 197
4 years ago
Edited 4 years ago

I have the admin give script to give admin commands to specific people. However, the script only seems to work only once when the player spawns, and will never work after that when they die. I tried it in new place without any other script than this script but still doesnt work, and also wont create any error.

local admins = {-1,-2,-3,-4,-5,-6}

local overHeadGui = game:GetService("ServerStorage").adminGUI:WaitForChild("adminLabel")
local admin = game:GetService("ServerStorage"):WaitForChild("adminGUI")

local owner = admin:WaitForChild("ownerCommands")
local staff = admin:WaitForChild("adminCommands")

game.Players.PlayerAdded:Connect(function(player)
    print("Player Joined")
    player.CharacterAdded:Connect(function(character)
        print("Respawn Detected")
        for i, v in pairs (admins) do
            if player.UserId == v then 
                print("admin is valid")
                if i == 1 then
                    print("owner detected")
                    print("the admin label is not valid yet")
                    local cloneGUI = overHeadGui:Clone()
                    cloneGUI.TextLabel.Text = "Owner"
                    cloneGUI.TextLabel.TextColor3 = Color3.fromRGB(150,138,189)
                    cloneGUI.TextLabel.Size = UDim2.new(0,100,0,50)
                    cloneGUI.Parent = character:WaitForChild("Head")
                    print("setted admin label")
                    local cloneAdmin = owner:Clone()
                    print(cloneAdmin.Name)
                    local adminGuiPlaceHold = player.PlayerGui:WaitForChild("adminGui")
                    cloneAdmin.Parent = adminGuiPlaceHold
                    for i,v in pairs(player.PlayerGui.adminGui:GetChildren()) do print(v.Name) wait() end
                    print("clone admin setted. Parent")
--                  for i,v in pairs (character:GetChildren()) do
--                      if v:IsA("BasePart") and v.Name ~="HumanoidRootPart" and  v.Name ~= "Head" then
--                          print("making it transparent")
--                          v.Transparency = .5
--                          v.Material = Enum.Material.Neon
----                            if v.Name == "Head" then
----                                v.Size  = Vector3.new(.5,.5,.5)
----                            elseif v.Name == "Torso" then
----                                v.Size = Vector3.new(2,2,.5)
----                            elseif v.Name == "LeftArm" or "RightArm" then
----                                v.Size = Vector3.new(1,5,1)
----                            end
--                      end
--                      if v.Name == "Head" then
--                          print("head transparent = 1")
--                          v.Transparency = 1
--                          for _,child in pairs(v:GetChildren()) do
--                              if child.Name == "face" then
--                                  print("face destroyed")
--                                  child:Destroy()
--                              end
--                          end
--                      end
--                  end
                    print("everything for owner done.")
                elseif i == 4 then
--                  for i,v in pairs (character:GetChildren()) do
--                      if v:IsA("BasePart") and v.Name ~="HumanoidRootPart" then
--                          v.Transparency = .5
--                          v.Material = Enum.Material.Neon
----                            if v.Name == "Head" then
----                                v.Size  = Vector3.new(.5,.5,.5)
----                            elseif v.Name == "Torso" then
----                                v.Size = Vector3.new(2,2,.5)
----                            elseif v.Name == "LeftArm" or "RightArm" then
----                                v.Size = Vector3.new(1,5,1)
----                            end
--                      end
--                  end

                    local cloneGUI = overHeadGui:Clone()
                    cloneGUI.TextLabel.Text = "Co-Owner"
                    cloneGUI.Parent = character:WaitForChild("Head")

                    local cloneAdmin = staff:Clone()
                    cloneAdmin.Parent =  player.PlayerGui:WaitForChild("adminGui")                  
                else

                    local cloneGUI = overHeadGui:Clone()
                    cloneGUI.Parent = character:WaitForChild("Head")

                    local cloneAdmin = staff:Clone()
                    cloneAdmin.Parent =  player.PlayerGui:WaitForChild("adminGui")
                end
            end
        end
        print("Every task done!")
        return
    end)
    print("out of char script")
end)

--How I Solved-- I found that I had the speed respawn script that respawned my character before anything else loads up. When I added extra seconds, the script started to work properly.

0
what does -1,-2 ect me lon233bcc 31 — 4y
0
It`s the user id of Player1, Player 2, etc.. I didn`t want to expose the userid of my staff so i changed it. Yuuwa0519 197 — 4y

Answer this question