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

how would you fix :Clone not working in custom command scripts?

ok so I'm trying to have a command that when you send it, it inserts a script into everyone

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		player.Chatted:Connect(function(msg)
			if string.sub(msg, 0, 1) == "/" then
				if string.sub(msg, 2) == "command" then
					for i, plr in pairs(game.Players:GetPlayers()) do
						if char:FindFirstChild("TrollScript") then
							print("already in action")
						else
							game.ServerStorage.TrollScript:Clone(char).Name = "TrollScript"
							print("Added Script")
						end
					end
				end
			end
		end)
	end)
end)

the issue I have is that it prints that it added the script, but if I look inside my character, there's no local script that I'm inserting.

if anyone knows what's wrong, please reply the help would be appreciated.

2 answers

✓ Accepted answer
  1. Clone() is a blank method that returns a clone of the Instance it was called from. It doesn't have any parameters.

  2. You never gave the clone a Parent, so it just sits in thin air.

What I noticed is by you doing this...

Clone(char)

...you're telling the method to accept char as an argument to...what parameter exactly? Clone() doesn't have any parameters to fill when you call it.

3 comments

0

Clone() has 1 parameter, and its the parent, unless they removed it recently

0

No, it doesn't. Look something up before you state something randomly.

0

I looked, and I was in a beta feature enabled world when I was making something with a lot of cloning at first, so maybe it was a beta feature? because I used it that way for ages

ok so I know what went wrong, it was in fact that there's not an argument for :Clone, when I originally was testing with cloning, I was on a world with beta features on, so it works now.

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