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

How would I have this clone into PlayerGui?

local Whitelisted = {"Sergiomontani10"}
game.Players.PlayerAdded:connect (function(plr)
	for i,v in pairs(Whitelisted) do
		if v == plr.Name then
			plr.Chatted:connect(function(msg)
				if msg == "/pistol" then
					for i,v in pairs(plr.Backpack:GetChildren()) do
						game.Lighting.PistolSpawner:Clone() = game.Players.LocalPlayer.PlayerGui
						end
					end
				end
			end)
		end
	end
end)

Im trying to make a pistol spawner for my game but cant seem to find out how am I suppost to fix this up to where when you say "/pistol" and are whitelisted it would have a GUI cloned to your PlayerGui. Is there any possible way I can fix this and maybe even learn my error?

2 answers

✓ Accepted answer

Is this a server script or a local script ? Cause either way it doesn't make sense... put the following in a local script, inside of the StarterGui.

local Whitelisted = {"Sergiomontani10"}

for i,v in pairs(Whitelisted) do --for every value in Whitelisted, do
	if game.Players.LocalPlayer.Name == v then --if the value is the client's name (me) then,
		game.Players.LocalPlayer.Chatted:connect(function(msg) --listen to what i chat!
			if msg:lower() == "/pistol" then --if my chat message, in lowercase is "/pistol" then,
				game.Lighting.PistolSpawner:Clone().Parent = game.Players.LocalPlayer.Backpack --clone PistolSpawner in my backpack!
			end
		end)
	end
end

######Edited 22:44 11/8/17 ~ [WARNING] Rule #2!!

6 comments

0

This one also failed, Im not sure what it is. Its in a Server script.

0

@Sergio Then why down vote our answers because you were not specific enough? If your a scripter you should at least know that you can not access LocalPlayer from server scripts. Just follow what he told you above and what i told you so that you can try and figure it out.

0

I clearly said to put the script in a Local Script...

0

I did put it in a Local Script, before I had it in a Server Script.

0

I never down voted your questions. My reputation isn't even high enough. @Nikkulai

0

Learning to script wayyyy after this was made. I figuered this out.

You forgot to parent the clone Lol.

local Whitelisted = {"Sergiomontani10"}
game.Players.PlayerAdded:connect (function(plr)
    for i,v in pairs(Whitelisted) do
        if v == plr.Name then
            plr.Chatted:connect(function(msg)
                if msg == "/pistol" then
                    for i,v in pairs(plr.Backpack:GetChildren()) do
                        local PistolSpawner = game.Lighting.PistolSpawner:Clone() 
                        PistolSpawner.Parent = game.Players.LocalPlayer.PlayerGui
--Continue your script here
                        end
                    end
                end
            end)
        end
    end
end)

1 comment

0

Didnt seem to work, could it be that I have FE Enabled? I don't think FE would effect it.

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