Indivdual Player?

I want indivdual player not certain name, I added 5. line, with my name and it work when i test it.

I try this variable, local plr = Game.Players:GetChildren() then i adapt d to plr[i]:Clone().Parent = game.Players <Picture include down below<

Doesn’t work if you put game. (plr[i]:Clone.Parent = game.Player.PlayerGui and on. – For single player

Please respone here if unclear.

2 Likes

U dont need that for i=1,# do u should made:

for i,v in pairs(d) do
If v:IsA("Model") then
--Do stuf
1 Like

Is this inside a local script? If so, you can just use game.GetService("Players").LocalPlayer. Otherwise, you can use something like this:

	local PlayerName = hit.Parent.Name
	local Player = game:GetService("Players"):FindFirstChild(PlayerName)

Use what @pro_developer213 said above to verify that hit is a direct descendant of the character model.

1 Like

How is it not working for you? Have you attempted to apply basic debugging to this situation first or reference the Developer Hub for help and API references?

Its script, not local script and lemme try that out, hold on.

You can change a few things. This probably wont fix it, but it will make the code better.

FIrst of, change connect to Connect. Change the for loop to an in pairs loop (for i, v in pairs() do). You can also use IsA() instead of class name. You can also put local before you define the function.

local function onTouch(hit)
    local d = hit.Parent:GetChildren()

    for i, v in next, d do -- pairs is the same thing as next
	   if v:IsA("Model") then
		   -- code
	   end
    end
 end

I suppose to do that, it just too long for me to explain, i did post description briefly and others do understand what i’m saying, especially with images.

I don’t mind to explain it again, Best for everybody to understaind If I upload on YT. It will take a while…

Ok, is your script a LocalScript or a ServerScript (normal Script)?

@Eternalove_fan32, He already mentioned above that it is a server script.

@Joshua7ninjaX , your post is very confusing. From what I can tell, you are trying to parent a clone into each person’s PlayerGui. You can achieve this by replacing:

game.Players.Joshua7ninjaX.PlayerGui.UMD.CurrentlyMorphs

With:

for _,plr in pairs(game.Players:GetPlayers()) do
     d[i].Clone().Parent = plr.PlayerGui.UMP.CurrentlyMorphs
end

This will clone everything that is a model inside of Players into everyone’s PlayerGui at that specified location. I am not sure if you wanted something different, but this is what I assume you’re asking for based on the information provided.

function onTouched(hit)
local d = hit.Parent:GetChildren()
for i,v_plr in pairs(game.Players:GetPlayers(d)) do
if v:IsA(“Model”) then – this will highlight Morphs(Arm1,Arm2.Chest,Head1,Leg1,Leg2)
d[i].Clone().Parent = plr.PlayerGui.UMP.CurrentlyMorphs – Invidual Player
end
end
end
end :arrow_backward: Underline with red?

script.Parent.Touched:connect(onTouched)

i will upload video to explain, sorry for delay.

In this example you have too many ends. Remove one to fix this version.

Although using i pairs would be better as @colbert2677 has indicated in similar posts in the past (you can implement that if you’d like )
I used a serverscript in the part , once touched , data is compared with data in an array to see if there’s a match, if yes then…

local players = game:GetService("Players")

local people ={
	
"Joshua7ninjaX";--though I recommend using ids instead
	
	}
script.Parent.Touched:Connect(function(hit)
    local touchedPlayer = players:GetPlayerFromCharacter(hit.Parent)
    if not table.find(people,touchedPlayer.Name) then return
	end --nothing happens if that player's name isnt found
        for _, loopedPlayer in pairs(players:GetPlayers()) do
            if loopedPlayer:FindFirstChild("PlayerGui") then 
                coroutine.wrap(function() 
                    local morphgui = loopedPlayer.PlayerGui.UMD.CurrentlyMorphs
                 morphgui.Visible = true
                    
                --[[    wait(3.3)
                    morphgui.Visible = false]]
                end)()
            end
        end
    
end)
I might have done an unnecessary loop, click here
local players = game:GetService("Players")

local people ={
	
"Joshua7ninjaX";--though I recommend using ids instead
	
	}
script.Parent.Touched:Connect(function(hit)
    local touchedPlayer = players:GetPlayerFromCharacter(hit.Parent)
    if not table.find(people,touchedPlayer.Name) then return
end --nothing happens if that player's name isnt found
     local player = players.LocalPlayer
            if player:FindFirstChild("PlayerGui") then 

                    local morphgui = player.PlayerGui.UMD.CurrentlyMorphs
                 morphgui.Visible = true
                    
                --[[    wait(3.3)
                    morphgui.Visible = false]]
                end)
            end
        
    
end)

I upload on YT here :arrow_down:

you can use the hit argument that is in the onTouched() function to find the player.

function touch(hit)
      If hit.Parent:FindFirstChild("Humanoid") then
           local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
      end
end
1 Like

It work! Coming from your post i have to edit the script and that is :+1: :+1: :+1: :fire: :fire:

1 Like

I do same, so dont Comments to only be an more comments here i am sure he know what i said

U posted this and thank anyway, i put bold here from your helped. Then PixelZombieX probably watch the video and post correctly.
for i,v in pairs(d) do
If v:IsA(“Model”) then
–Do stuf


function touch(hit)
local d = hit.Parent:GetChildren()
for i,v in pairs(d) do
if v:IsA(“Model”) then – this will highlight Morphs(Arm1,Arm2.Chest,Head1,Leg1,Leg2)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent) – Invidual Player
if hit.Parent:FindFirstChild(“Humanoid”) then
d[i]:Clone().Parent = plr.PlayerGui.UMD.CurrentlyMorphs
end
end
end
end

script.Parent.Touched:connect(touch)