Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to give player specified gui when they chat gui ?

Here's what i've got so far.

game.Players.PlayerAdded:connect(function(player)
 if player.Name == "noobs88" then
player.Chatted:connect(function(msg)
if msg == "gui" then
game.Lighting.UploadLimited:Clone().Parent = game.Players.noobs88.PlayerGui
end
end
end)
end)

4 comments

0

This looks like it should work. What exactly is the problem?

0

I would store gui's in StarterGui, why is it in lighting???

0

It was just where I was keeping it

0

I see your problem, the parenthesis that you have on line 8 is actually supposed to be on line 7. Line 8 is the end to the if then statement, and line 7 is the end of the chatted event.

2 answers

local admins = {"noobs88", "aquathorn321"} --List of people who can use the command
game.Players.PlayerAdded:connect(function(player)
local admin = false
for i,v in pairs(admins) do --cycles through admin list to see if any of the names match
if player.Name:lower() == v:lower() then
admin = true
break
end
if admin then
player.Chatted:connect(function(msg)
if msg:lower() == "gui" and not player.PlayerGui:FindFirstChild("UploadLimited") then --checks to see if the gui already exists and if the player used the command
local gui = game.Lighting.UploadLimited:Clone() --Creates a clone of the gui
gui.Parent = player.PlayerGui --puts the clone into the player's playergui
end
end)
end
end)

The only problem with your script was that you created the clone and parented it in the same line. This won't work, as the merciless garbage collector just eats it up. I recommend moving the gui to replicated storage and check to see if the player already has the gui before cloning it again. I went ahead and fixed the second part for you.

I haven't tested this in studio, so let me know if it gives you any problems

1 comment

0

You actually can clone and parent an object in the same line. Now if you're manipulating multiple properties, then you'll want to use a variable for the clone.

game.Players.PlayerAdded:connect(function(player)
 if player.Name == "noobs88" then
player.Chatted:connect(function(msg)
if msg == "gui" then
repeat wait() until game.Players.noobs88.PlayerGui
game.Lighting.UploadLimited:Clone().Parent = game.Players.noobs88.PlayerGui
end
end
end)
end)

See if that fixes it

This discussion is preserved as it was. New answers, comments, and votes are closed.