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

How to give player specified gui when they chat gui ?

Asked by
h19rry 20
9 years ago

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)

0
This looks like it should work. What exactly is the problem? Perci1 4988 — 9y
0
I would store gui's in StarterGui, why is it in lighting??? dragonkeeper467 453 — 9y
0
It was just where I was keeping it h19rry 20 — 9y
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. M39a9am3R 3210 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago
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

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. M39a9am3R 3210 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
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

Answer this question