Cloning into StarterPlayerScripts, or PlayerScripts is not working?

Hello! I am trying to clone a ModuleScript into either StarterPlayerScripts, or PlayerScripts, yet it is not working.
I am using a Child Script in the Module Script currently (not working, incase you didn’t get that before)

local module = script.Parent
local moduleclone = module:Clone()
local Players = game:GetService(“Players”)
Players.PlayerAdded:Connect(function(player)
local scriptclone = script:Clone()
scriptclone.Parent = player:FindFirstChild(“PlayerScripts”)
end)
wait(1)

(Sorry, still not familiar with all the Features of Devforum… :flushed:)

Anyway, can someone tell me what I am doing wrong? How can I get the Module Script into PlayerScripts, without manually putting it inside the StarterCharacterScripts, because it will use a Loadstring, from a Product.

Thanks, AridOats.

1 Like

Sorry, at that end bit I meant to write StarterPlayerScripts, and I got mixed up.

It’s as simple as this!

--lets assume the module script is currently a child of this server script

game.Players.PlayerAdded:Connect(function(player)
local mclone = script.ModuleScript:Clone()
mclone.Parent = player.PlayerScripts
end)

since am on phone there may be some minor errors with that.

Use ``` at the beginning and end to get the lua script format.

Sorry, it’s still not working! I’m getting the following Error:

PlayerScripts is not a valid member of Player "Players.AridOats"  -  Server - Script:3

This is the Same Error I got before.

I did try to fix the error by doing the following:

game.Players.PlayerAdded:Connect(function(player)
local mclone = script.ModuleScript:Clone()
mclone.Parent = player:WaitForChild("PlayerScripts")
end)

But that did not work, and there is no error in the output.

Also, thanks for telling me how to create Code Blocks!

Yeah because PlayerScripts folder doesn’t exist on server so you can’t parent the module there.

1 Like

Ok, so what do you suggest I do? Is the WaitForChild:() action a good idea, and I’m just not doing it right?

Using Player:WaitForChild("PlayerScripts") will absolutely do nothing other than yield the coroutine forever since the script you gave runs on server and PlayerScripts folder never replicates to server.

Ok, do you have a Suggestion on what I can use then?

I would parent it to the player’s PlayerGui folder.

Can you give a Code Example? The problem is, it needs to be in the PlayerScripts. Here is the full Module script:

local module = {}

module.addMaskToPlayer = function()
	local Players = game:GetService("Players")
	local playerModel = script.Parent
	local humanoid = playerModel:WaitForChild("Humanoid")

	local clockworksShades = Instance.new("Accessory")
	clockworksShades.Name = "DoctorsMask"

	local handle = Instance.new("Part")
	handle.Name = "Handle"
	handle.Size = Vector3.new(1,1.6,1)
	handle.Parent = clockworksShades

	local faceFrontAttachment = Instance.new("Attachment")
	faceFrontAttachment.Name = "FaceFrontAttachment"
	faceFrontAttachment.Position = Vector3.new(0,0.2,-0.35)
	faceFrontAttachment.Parent = handle

	local mesh = Instance.new("SpecialMesh")
	mesh.Name = "Mesh"
	mesh.Scale = Vector3.new(1,1.3,1)
	mesh.MeshId = "rbxassetid://5217114854"
	mesh.TextureId = "rbxassetid://5217114928"
	mesh.Parent = handle

	humanoid:AddAccessory(clockworksShades)
end

return module

Can it only work when placed into PlayerScripts? I don’t really know why this wouldn’t work in PlayerGui.

Why do you need to clone it? Just put it in StarterPlayerScripts.

2 Likes

I am using it as a Product, and a require() for the Module.

I have tried, but it does not work unfortunately. The Script clones into the right place, but the Module does not work.

Then I can’t help you sadly, i’m not that experienced when it comes to modulescripts unfortunately.

If the module doesn’t work then it’s an issue with the module.

1 Like

Product for what? What are you trying to achieve?

1 Like

For example, the buyer will insert the Loadstring into the game, and it’s done, a mask will appear on all the players faces. I don’t want to make any hassle for the buyers, and I want to keep my product’s source code safe.

As they said, the server cannot access PlayerScripts, so you could put the module in another folder or create it.

local Module =
game:GetService("Players").PlayerAdded:Connect(function(Player)
    local Folder = Instance.new("Configuration",Player)
    Folder.Name = "Extra"
    Module:Clone().Parent = Folder
end)

This is pointless, client side code will always be sourced by exploiters. You can’t prevent it.

2 Likes