Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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)

0
Your trying to clone all the tools mentioned in the table? SwiftyDeveloper 4 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

1) try changing

local Tool = Storage:FindFirstChild(ToolNames)

to...

local Tool = Storage.ToolNames

and

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

Hopefully that works! :)

0
This is a localscript DatBroDo -6 — 4y
Ad

Answer this question