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

How do I replicate tools in ServerStorage to the players backpack using a button?

I'm trying to do so that when you press "Join" for instance, you are put into the game and are given the tools in ServerStorage.

I tried making this script, I placed prints to check where it went wrong and it only prints the first two. The problem here is it's not replicating to the player's backpack with no errors as well.

script.Parent.MouseButton1Click:Connect(function(Player)
	script.Parent.Parent.Enabled = false
	workspace.Camera.CameraType = Enum.CameraType.Custom
	workspace.CurrentCamera.Blur.Enabled = false
	
	print("We're halfway theeere, WOAAAH")
		
		local Storage = game:GetService("ServerStorage")
		local ToolNames = {"Key-L0", "Key-L1", "Key-L2", "Key-L3", "Key-L4", "Key-L5"}
		local Player = game.Players.LocalPlayer
	if Player and Player.Character then
		local Tool = Storage:FindFirstChild(ToolNames)
   	
	print('LEMON AND A PEARRR')
	
	if Tool then
	Tool:clone().Parent = Player.Backpack
	
	print('UNO DOS TRESS')
		end
	end
end)

1 comment

0

Your trying to clone all the tools mentioned in the table?

1 answer

  1. try changing
local Tool = Storage:FindFirstChild(ToolNames)

to...

local Tool = Storage.ToolNames

and

  1. You cannot have LocalPlayer reference in a Regular Script try fetching player data using the GetPlayers service

Hopefully that works! :)

1 comment

0

This is a localscript

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