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

How do I make a button clones when a player joins through a local script?

Asked by 3 years ago

I want to make a scrolling frame, and there's buttons in the scrolling frame. When a player joins, i want the button to clone and the button text is the player's text and when they leave the button gets destroy or disappear. The things is, I can't make it on local script and I need to do it on local script.

0
Maybe try with remote events. xsodar 19 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago

Pretty sure that local scripts can still use Players.PlayerAdded so this might work


game.Players.PlayerAdded:Connect(function(player) local newbutton = scrollingframe.Button:Clone() newbutton.Name = player.Name -- using player name here to find button later newbutton.Text = player.Name newbutton.Parent = scrollingframe end) game.Players.PlayerRemoved:Connect(function(player) if scrollingframe:FindFirstChild(player.Name) -- checks if theres a button for the player scrollingframe:FindFIrstChild(player.Name):Destroy() end end)

Just change up the button references cause idk what u use for it

Hope that helped

0
I already know how to, and yeah your answer is correct well done.' WINDOWS10XPRO 438 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I don't know if this is what you meant but..

--server script

local addEvent = game.ReplicatedStorage.addEvent local removeEvent = game.ReplicatedStorage.removeEvent

game.Players.PlayerAdded:Connect(function(player) addEvent:FireAllClients(player) end

game.Players.PlayerRemoved:Connect(function(player) removeEvent:FireAllClients(player) end

--local script

local addEvent = game.ReplicatedStorage:WaitForChild("addEvent") local removeEvent = game.ReplicatedStorage:WaitForChild("RemoveEvent")

addEvent.OnClientEvent:Connect(function(player) local buttonClone = button:Clone() buttonClone.Text = player.Name buttonClone.Name = player.Name end

removeEvent.OnClientEvent:Connect(function(player) screenGui:FindFirstChild(player):Destroy() end

Let me know if you have any issues.

--remote eventless method?

local localPlayer = game.Players.LocalPlayer

game.Players.PlayerAdded:Connect(function(player) local buttonClone = button:Clone() buttonClone.Parent = localPlayer.PlayerGui.ScreenGui buttonClone.Text = player.Name buttonClone.Name = player.Name end

game.Players.PlayerRemoved:Connect(function(player) localPlayer.PlayerGui.ScreenGui:FindFirstChild(player.Name):Destroy() end

0
i dont wnt to use remote events WINDOWS10XPRO 438 — 3y
0
i know how to do that, but i dont know how to do it without remote events. other people can do it. WINDOWS10XPRO 438 — 3y
0
its not possible without remote events, you can't communicate between clients LeedleLeeRocket 1257 — 3y
0
i'll edit my post, see if this works. LeedleLeeRocket 1257 — 3y
0
it is possible. Like I thought instance.new can't be FE through a local script, but there's actually a way to make it FE WINDOWS10XPRO 438 — 3y

Answer this question