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

How come my 'Hologram' command/code isn't working properly?

Asked by 9 years ago

What I mean: I have created a command for my A.C. (Admin Commands), however, the command is not working as it is supposed to, although, as it is executing the command, the for loop is not looping properly through the Hologram, as the face, HumanoidRootPart, and Hat(s) are appearing up in the Hologram when not supposed to, I have even set a Wait to wait before starting the for loop, however, that did not prevent from the face, HumanoidRootPart, nor the Hat(s) from showing up either, however, it is setting the Transparency, and BrickColor for the BasePart's, which is what it is also supposed to do, but, I am confused to why it won't do the same for the rest of the things I listed (The face, HumanoidRootPart, and Hat(s)).

This is the code I am using for the Hologram (Note, this is the entire Hologram code :) );

if msg:lower():sub(1,9+#Prefix) == Prefix.."hologram " then
    local plrz = GetPlr(plr,msg:sub(10+#Prefix)); print("Hologram 1:",#plrz)
    for i,v in pairs(plrz) do print("Hologram 2")
        coroutine.resume(coroutine.create(function() print("Hologram 3")
            if v.Character then
                v.Character.Archivable = true
                local char = v.Character:Clone()
                char.Parent = Services['Workspace']
                char:MakeJoints()
                char.Name = v.Name.."HOLOGRAM"
                char:MoveTo(v.Character:GetModelCFrame().p+Vector3.new(0,1,0))
                table.insert(Container,char)
                wait(.5)
                for i2,v2 in pairs(char:GetChildren()) do
                    if v2:IsA("BasePart") then
                        v2.BrickColor = BrickColor.new("Teal")
                        v2.Transparency = 0.1
                    elseif v2:IsA("Hat") and v2:FindFirstChild("Handle") then
                        if v2:FindFirstChild("Mesh") then
                            v2.Mesh.TextureId = "http://"
                            v2.VertexColor.X = 0
                            v2.VertexColor.Y = 1
                            v2.VertexColor.Z = 1
                        end
                        v2.Handle.BrickColor = BrickColor.new("Teal")
                        v2.Handle.Transparency = 0.1
                    elseif v2:FindFirstChild("face") then
                        v2.face:Destroy()
                        wait(1/13.37)
                        if v2:FindFirstChild("face") then
                            v2.face.Texture = "http://" 
                            v2.face.Transparency = 1
                        end
                    elseif v2.Name == "HumanoidRootPart" then
                        v2.Transparency = 1
                    end
                end
            v.Character.Archivable = false
            end
        end))
    end
end
0
Would you mind putting a ypcall function on the code? I make highly advanced admin's, Im used to having odd error's like this; I would think the coroutine is masking the error from showing due to the coroutine threading the function to the Render-Engine instead of the Server. MessorAdmin 598 — 9y
0
Oh, I forgot the coroutine I used is not so Flexible. :P I tried using this coroutine, since 'coroutine.wrap' did not give me the legitimate error. Also, how would I use the 'ypcall' in the function; I do not understand 'pcall''s anymore, since in the past, I figured I've been using them wrong. TheeDeathCaster 2368 — 9y
0
I just switched it from a 'coroutine' to 'spawn', but sadly, there is no error coming up, and the same affect is still occuring. TheeDeathCaster 2368 — 9y
0
Spawn in a nother form of coroutine. :P MessorAdmin 598 — 9y
View all comments (4 more)
0
I like making using a table to run a admin, it just run's more smooth and less laggy; If you would like to know a little more info on that method message me and I will explain it. MessorAdmin 598 — 9y
0
What do you mean by 'using a table to run a admin'? I do not understand. TheeDeathCaster 2368 — 9y
0
local Commands = { {Cmd = "Hologram",Rank = 3 , Func = function() end} } then have the CheckChat run the function in the table. MessorAdmin 598 — 9y
0
That seems difficult. o_e Also, sorry for slow responses, there is connection problems going on around where I am. :/ TheeDeathCaster 2368 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

I got this code working hardly in any time at all, it was a simple mistake; the .Chatted connection. :P

I would also recommand using my GetPlr function, I made mine so even if your msg is a nil it will refer to you.

local Prefix = "!"
local Container = {}

local GetPlr=function(Plr,Msg) local ReturnedTable={} -- Use mine if you would like.
if Msg:lower()=='me' or Msg=='' then table.insert(ReturnedTable,Plr)
elseif Msg:lower()=='all' then coroutine.wrap(function() for _,v in pairs(game.Players:GetPlayers()) do table.insert(ReturnedTable,v) end end)()
elseif Msg:lower()=='others' then for _,v in pairs(game.Players:GetPlayers()) do if v.Name~=Plr.Name then table.insert(ReturnedTable,v) end end
elseif Msg:lower()=='friends' then for _,v in pairs(game.Players:GetPlayers()) do if v:IsFriendsWith(Plr.userId) then table.insert(ReturnedTable,v) end end
elseif Msg:lower()=='bestfriends' then for _,v in pairs(game.Players:GetPlayers()) do if v:IsBestFriendsWith(Plr.userId) then table.insert(ReturnedTable,v) end end
elseif Msg:lower()=='nonfriends' then for _,v in pairs(game.Players:GetPlayers()) do if not v:IsFriendsWith(Plr.userId) then table.insert(ReturnedTable,v) end end
elseif Msg:lower()=='nonbestfriends' then for _,v in pairs(game.Players:GetPlayers()) do if not v:IsBestFriendsWith(Plr.userId) then table.insert(ReturnedTable,v) end end
elseif Msg:lower()=='nbc' then for _,v in pairs(game.Players:GetPlayers()) do if v.MembershipType == Enum.MembershipType.None then table.insert(ReturnedTable,v) end end
elseif Msg:lower()=='tbc' then for _,v in pairs(game.Players:GetPlayers()) do if v.MembershipType == Enum.MembershipType.TurboBuildersClub then table.insert(ReturnedTable,v) end end
elseif Msg:lower()=='obc' then for _,v in pairs(game.Players:GetPlayers()) do if v.MembershipType == Enum.MembershipType.OutrageousBuildersClub then table.insert(ReturnedTable,v)end end
elseif Msg:lower()=='anybc' then for _,v in pairs(game.Players:GetPlayers()) do if v.MembershipType==Enum.MembershipType.BuildersClub then elseif v.MembershipType==Enum.MembershipType.TurboBuildersClub then elseif v.MembershipType==Enum.MembershipType.OutrageousBuildersClub then table.insert(ReturnedTable,v) end end 
else for _,v in pairs(game.Players:GetPlayers()) do local NM=v.Name:lower() local Msg=Msg:lower() if NM:sub(1,5):lower():find(Msg) then table.insert(ReturnedTable,v) end end end wait() return ReturnedTable
end

CheckChat = function(plr,msg)
if msg:lower():sub(1 ,9+#Prefix ) == Prefix.."hologram " then --  !hologram<spacehere>
    local plrz = GetPlr(plr,msg:sub(10+#Prefix)); print("Hologram 1:",#plrz)
    for i,v in pairs(plrz) do print("Hologram 2")
        coroutine.resume(coroutine.create(function() print("Hologram 3")
    local rc,ec = ypcall(function()
            if v.Character then
                v.Character.Archivable = true
                local char = v.Character:Clone()
                char.Parent = workspace
                char:MakeJoints()
                char.Name = v.Name.."HOLOGRAM"
                char:MoveTo(v.Character:GetModelCFrame().p+Vector3.new(0,1,0))
                table.insert(Container,char)
                wait(.5)
                for i2,v2 in pairs(workspace[char.Name]:GetChildren()) do
                   if v2.ClassName == 'Part' and v2:IsA('BasePart') then
                        v2.BrickColor = BrickColor.new('Teal')
                        v2.Transparency = tonumber( .1 )
                   end
                    if v2.ClassName == 'Hat' and v2:FindFirstChild('Handle',true) then
                        if v2.Handle:FindFirstChild('Mesh',true) then
                            v2.Handle.Mesh.TextureId = ""
                        end
                    end
                    if v2.ClassName == 'Shirt' then
                        v2:remove()
                    end
                    if v2.ClassName == 'Pants' then
                        v2:remove()
                    end
                    if v2.ClassName == 'ShirtGraphic' then
                        v2:remove()
                    end
                    if v2:FindFirstChild('Head',true) and v2.Head:FindFirstChild('face',true) then
                        v2.Head.face.Texture = ''
                        v2.Head.face.Transparency = 1
                    end
                end
            v.Character.Archivable = false
            end
    end)
    if not rc then warn( tostring(ec) ) end
       end))
    end
end
end

game.Players.PlayerAdded:connect(function(plr)
    plr.Chatted:connect(function(msg)
        CheckChat(plr,msg)
    end)
end) 

0
Line 4-17 is burning my eyes, man :( Perci1 4988 — 9y
0
Lol, if you saying its crapy coding I just threw it together in like 2 minutes. :P MessorAdmin 598 — 9y
2
It's just messy, lol. Perci1 4988 — 9y
0
Your 'GetPlr' function is set up only to respond to Player's individually (E.x.: '!kill Player1' will work, while '!kill Player1,Player2' will not), also, I already have a 'GetPlr' function, but thanks for the thought. :) TheeDeathCaster 2368 — 9y
View all comments (7 more)
0
Np. MessorAdmin 598 — 9y
0
Also, as the original Question, do you know why the 'For' loop within the 'coroutine' is not looping through the 'Hologram' properly? XP TheeDeathCaster 2368 — 9y
0
What line? From when I ran it in my studio it seemed to run fine. MessorAdmin 598 — 9y
0
The lines where it is not working properly are lines 18 and 27 (for their code, they are not doing as supposed to). TheeDeathCaster 2368 — 9y
0
Mk. Sorry Im responding so slow; Im really busy making Stetch a gui. :L MessorAdmin 598 — 9y
0
It's Ok. :) TheeDeathCaster 2368 — 9y
0
Try the code now. I believe is should remove the clothing etc... MessorAdmin 598 — 9y
Ad

Answer this question