Small Scripting Problem

Hi Guys, Small script problem. My player isin’t receiving a knife when the round starts, I can’t figure out what the problem could be since I thought I did it properly. Here is the code:

local Knife = ServerStorage.Knife:Clone()
Knife.Parent = player.Backpack

This is the line of code that refers to them actually receiving the knife, I can send other pieces of code to provide context if asked.

wouldn’t use server storage, use replicatedstorage instead

Make sure the script cloning and parenting the knife into the players backpack is a server-script. Can you show us full code?

As I said, there isin’t any code that actually deters this line of code I think But I will show the surrounding script as you asked. One problem that could happen is that it is in the same function as some other line of codes? I don’t know I’m still a new scripter. Here is the surrounding code:

for i, player in pairs(plrs) do
if player then
character = player.Character

	if character then
		-- Teleport them

		character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
		table.remove(AvailableSpawnPoints,1)


		

		local Knife = ServerStorage.Knife:Clone()
		Knife.Parent = player.Backpack

		local GameTag = Instance.new("BoolValue")
		GameTag.Name = "GameTag"
		GameTag.Parent = player.Character

	else
		-
		if not player then
			table.remove(plrs,i)
		end
	end
end

end

What would the difference be between them?

Replicatedstorage which is my choice for storing objects and stuff in there and it’s made for storing objects such as parts, meshes, models and other stuffs and to be used by both Local Script and Server script

ServerStorage which doesn’t really a good choice for storing object because ServerStorage is made for player’s data and configurations and ServerStorage can’t be used by Local Script but only Server Script

So basically, if the script you having here is local script, the script won’t of course can not access to the server storage in order to clone to knife you want

There’s a big difference between ReplicatedStorage and ServerStorage and how they operate.

  1. ServerStorage is a container used to store objects and assets that are only needed on the server. Objects placed in ServerStorage are not replicated to the client and can only be accessed and used by server scripts. This storage container is commonly used to store server-specific assets, such as server scripts, server-only models, or other resources that should not be accessible or visible to players.

  2. ReplicatedStorage is a container used to store objects and assets that need to be replicated to both the server and the clients. Objects placed in ReplicatedStorage are synchronized across the server and all connected clients, allowing them to be accessed and used by both serverScripts and LocalScripts (perhaps ModuleScripts too, they can access both server and client). This storage container is commonly used to store shared assets, such as scripts, models, sounds, RemoteEvents/RemoteFunctions or other resources that need to be accessible by both the server and the clients.