#Clone function isn't working

1 messages · Page 1 of 1 (latest)

full bay
#

I have a remote event connect function in a localscript which clones a frame instance, but its not working

#

Script fragment for reference:

local unit = game:GetService("ReplicatedStorage").PlayerUnit
local uic = unit.UICorner
local uis = unit.UIStroke
local img = unit.ImageLabel
local tex = unit.TextLabel
local usern = player.Name
local nickn = player.DisplayName
local gui = game:GetService("StarterGui").MenuGui.PlayerFrame

game:GetService("ReplicatedStorage").PlayerIcon.OnClientEvent:Connect(function(plr, voting)
    if voting == true then
        local i = unit:Clone()
        i.Parent = gui
        i.Name = usern
        i.TextLabel.Text = nickn
        i.Visible = true
    else
        gui:WaitForChild(usern):Destroy()
    end
end)```
south sleet
#

maybe you need more nesting

long jasper
#

does the event ever reach the client?

full bay
full bay
sly citrus
south sleet
full bay
full bay
full bay
# patent fractal show :fireclient() code
game:GetService("ReplicatedStorage").RemoteEvent.OnServerEvent:Connect(function(plr, voting)
    game:GetService("ReplicatedStorage").PlayerIcon:FireAllClients(plr, voting)
end)```
south sleet
full bay
#

also this is not the point rn im trying to solve a clone problem

south sleet
full bay
#

also now that i think about it no its not nesting more its in fact nesting less since i removed a layer which would be the custom function itself

#

;-;

#

anyways!

#

"swame issue"

#

do you realise

#

earlier issue

#

was solved

#

by doing something totally unrelated

#

😭

south sleet
#

yk what solve your things yourself

full bay
#

im making a player thingie like piggy so no shit i have to load all the info from the remote event

south sleet
#

ITS A FUCKING LOCAL SCRIPT DO Players.LocalPlayer

full bay
#

no

#

what i mean is

#

all players

#

so individually is plr parameter

south sleet
#

loop through game.Players

#

as if that wouldnt work

full bay
#

excuse me?

#

wait...

#

you mean like an actual loop

south sleet
#

You just dont understand roblox game engine and your also not taking advice

full bay
#

the whole point of remote events is to avoid having to always reoccur to loops

south sleet
#

Your like a patient for a doctor that is not taking his medicine the doctor gave him

full bay
full bay
#

atleast you know how to spell nest you made sure about that 💜

south sleet
#

your gonna quit coding in the next week anyway why am I even caring abt this

full bay
#

anywaysss

#

so um my gui is still not working-

sly citrus
full bay
#

also if yall wanna keep replying maybe do it otherwhere... i still need help with my gui and yall flooded the chatt

cobalt wharfBOT
#

studio** You are now Level 14! **studio

full bay
#

;_;

#
local unit = game:GetService("ReplicatedStorage").PlayerUnit
local uic = unit.UICorner
local uis = unit.UIStroke
local img = unit.ImageLabel
local tex = unit.TextLabel
local usern = player.Name
local nickn = player.DisplayName
local gui = game:GetService("StarterGui").MenuGui.PlayerFrame

game:GetService("ReplicatedStorage").PlayerIcon.OnClientEvent:Connect(function(plr, voting)
    print("hai")
    if voting == true then
        local i = unit:Clone()
        i.Parent = gui
        i.Name = usern
        i.TextLabel.Text = nickn
        i.Visible = true
    else
        gui:WaitForChild(usern):Destroy()
    end
end)```
#

anyways this is the script now

#

and yes i did remove the plr parameter again and yes it didnt work 🙄

sly citrus
#

where u getting plr nd voting from

full bay
#

server

sly citrus
#

isnt it player

full bay
vital depot
#

.PlayerGui

full bay
#

oh

#

i think i already did that but lemme retry!

vital depot
#

player variable

#

local plr = game.Players.LocalPlayer

sly citrus
#

yea i thought that also

#

but wasnt sure, only been learnin 2 days

full bay
vital depot
full bay
#

plr is the loaded player to display its name and avatar

#

player is game:FindService("Players").LocalPlayer

vital depot
#

what

#

@proud falcon

#

💔

full bay
#

plr is basically everyone pressing play so it clones it to display, like piggy

#

player is the player client itself

sly citrus
#

im so lost

vital depot
#

??

sly citrus
#

what are u sayin

vital depot
#

idk what they talking about

full bay
#

what i did is

vital depot
#

plr is just my variable name

#

and i get the LocalPlayer

full bay
#

i ran a remoteevent from a client to a server

vital depot
#

local plrs = game:GetService(“Players”)

#

this is for all players

full bay
#

what i did with this is basically i can load anyone's info apart from just loading player client info

proud falcon
proud falcon
full bay
#

oh shit

#

yes ik i just forgot to change that from previous mistakes

#

lemme try now!

proud falcon
#

wheres the error

full bay
#

... getservice doesnt make it work either

vital depot
proud falcon
#

show code

full bay
proud falcon
#

ok logic error

full bay
proud falcon
#

bro

full bay
#

lemme recopypaste

proud falcon
#

ok

full bay
#
local unit = game:GetService("ReplicatedStorage").PlayerUnit
local uic = unit.UICorner
local uis = unit.UIStroke
local img = unit.ImageLabel
local tex = unit.TextLabel
local usern = player.Name
local nickn = player.DisplayName
local gui = player.PlayerGui

game:GetService("ReplicatedStorage").PlayerIcon.OnClientEvent:Connect(function(plr, voting)
    print("hai")
    if voting == true then
        local i = unit:Clone()
        i.Parent = gui
        i.Name = usern
        i.TextLabel.Text = nickn
        i.Visible = true
    else
        gui:WaitForChild(usern):Destroy()
    end
end)```
proud falcon
#

run this

vital depot
#

i figured it out

proud falcon
#
local unit = game:GetService("ReplicatedStorage").PlayerUnit
local uic = unit.UICorner
local uis = unit.UIStroke
local img = unit.ImageLabel
local tex = unit.TextLabel
local usern = player.Name
local nickn = player.DisplayName
local gui = player.PlayerGui

game:GetService("ReplicatedStorage").PlayerIcon.OnClientEvent:Connect(function(voting)
    if voting == true then
        local i = unit:Clone()
        i.Parent = gui
        i.Name = usern
        i.TextLabel.Text = nickn
        i.Visible = true
    else
        gui:WaitForChild(usern):Destroy()
    end
end)```
#

also show serverside

#

oh yes

#

onclientevent does not fire client

#

its a reference to which client needs firing

#

youre probably using voting as plr

#

there

full bay
#

what

#

lemme print to prove what you saying

#

nope its all well sorted out

#

plr = Daparty75 (me) voting = true

proud falcon
#

-- Server

event:FireClient(game.Players.closurebased, "Hello world!") -- 1st param is an indicator to which client should receive the signal

proud falcon
#

if ur using

#

fireallclients

vital depot
proud falcon
#

youre not using the client arg either

full bay
#

im firing to all clients each player's info so they all have the player's info

proud falcon
#

this uses ur local players nickname

#

not the player you got from the event

full bay
#

so actually

#

i didnt use plr

#

my bad

#

it still doesnt work but still lemme share it to yall

proud falcon
#

.Name too

full bay
#
local unit = game:GetService("ReplicatedStorage").PlayerUnit
local uic = unit.UICorner
local uis = unit.UIStroke
local img = unit.ImageLabel
local tex = unit.TextLabel
local gui = player.PlayerGui

game:GetService("ReplicatedStorage").PlayerIcon.OnClientEvent:Connect(function(plr, voting)
    print(plr, voting)
    if voting == true then
        local i = unit:Clone()
        i.Parent = gui
        i.Name = plr.Name
        i.TextLabel.Text = plr.DisplayName
        i.Visible = true
    else
        gui:WaitForChild(plr.Name):Destroy()
    end
end)```
#

now i am actually using the parameter to load the info i want

proud falcon
#

can u send explorer image

#

after you receive the event

#

in your playergui

full bay
#

what

proud falcon
#

like

#

and go playergui

#

send image

full bay
#

lemme see

#

oh wait should i put it under menugui???

proud falcon
#

ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

wait

#

lol

#
local unit = game:GetService("ReplicatedStorage").PlayerUnit
local uic = unit.UICorner
local uis = unit.UIStroke
local img = unit.ImageLabel
local tex = unit.TextLabel
local gui = player:WaitForChild("PlayerGui")

game:GetService("ReplicatedStorage").PlayerIcon.OnClientEvent:Connect(function(plr, voting)
    print(plr, voting)
    if voting == true then
        local i = unit:Clone()
        i.Parent = gui
        print(i.Parent)
        i.Name = plr.Name
        i.TextLabel.Text = plr.DisplayName
        i.Visible = true
    else
        gui:WaitForChild(plr.Name):Destroy()
    end
end)```
#

for instances that are generated during runtime you need to use waitforchild

full bay
#

OMG

proud falcon
#

if you dont, they are nil

full bay
#

YALL

#

THE ERROR WAS MENUGUI NOT BEING THE PARENT

sly citrus
#

not our fault tho

full bay
#

well i mean

#

thanks for trying to help

proud falcon
#

you can parent frames n shi

#

to playergui

full bay
#

yall kidna led me the right way tho

proud falcon
#

it wont show it

sly citrus
#

but all good

south sleet
#

i should have smelled the explorer obv

full bay
#

if anything im the first one to believe people can help specially when those ai bros show up