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

For some reason the item gets cloned but doesn't appear in my backpack?

Asked by 5 years ago
local Tool = script.Parent.BetterCuter

local Player = game.Players.LocalPlayer



script.Parent.MouseButton1Click:Connect(function()

Tool:Clone()

Tool.Parent = game.StarterPack

end)
0
i think starterpack is for when the player joins the game, it will automatically clone it into their backpack. What you should do is put it directly into the players backpack, but im not exactly sure this solution works... MoonBarc 24 — 5y
0
ok ill try Narrowlegobricks 12 — 5y
0
You have to use a remote event. ChefDevRBLX 90 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You are using a localscript to clone these into your backpack and StarterGear.

For starters, Backpack is what you have and can currently equip with your numeric keybinds, StarterGear is what you will always respawn with. So, "StarterPack," will automatically clone to startergear for the player, but Backpack will not do such a thing, however, do NOT put this on the client. Use a RemoteEvent instead!

I would also like you to move that tool into some place that the localscript is not, maybe a folder inside of ServerStorage or ReplicatedStorage for now, since we won't need the tool replicated to the client at all, I'll put the tool inside of ServerStorage in this example.

To start off, create a Remote Event inside of ReplicatedStorage, name it anything, for the purpose of explaning, I'll call it, "Event", now! On the client side.

script.Parent.MouseButton1Click:Connect(function()
        game.ReplicatedStorage.Event:FireServer()
end)

This is all you really need for that, although I develop my games with 1 Remote Event and would set this up completely different due to my game's requirements, for now, you don't need to worry about that. All you need to know is this Fires to the server and it allows you to access server sided components that the server needs to know by a click of a button that is on the client side.

Now, what we'll want to do next is make an Event called OnServerEvent now what this does is whenever the client fires to the server with the Event in ReplicatedStorage, it will run the code in that event.

Let's get started on that then, shall we?

local tool = game.ServerStorage.BetterCutter
game.ReplicatedStorage.Event.OnServerEvent:Connect(function(player)
        local newTool = tool:Clone()
        newTool.Parent = player.Backpack
        local newTool2 = tool:Clone()
        newTool2.Parent = player.StarterGear
end)

Alright! Now, I would also like to state the the first argument in OnServerEvent is ALWAYS the player argument, meaning,

player = game.Players["PERSON WHO CLICKED THE TEXTBUTTON"]

Obviously that's not a actual code, but you get my drift I assume, and given that Backpack and StarterGear are in fact valid members of Player, they clone successfully and you now have yourself a successful tool cloning system.

0
Actually, that's only partially true. "player" is the player who triggered the event. This is not enitrely related to the player's UI nor is it enitrely related to their input. DeceptiveCaster 3761 — 5y
Ad

Answer this question