My Tool Wont Show

Getting to the point, I want my character at a certain point to get something into there inventory, but, I looked at the explorer window and it popups, but doesn’t show in my game.

The Script I used:

--- local burger = game.ServerStorage.Burger:Clone()
    burger.Parent = game.StarterPack

Why wont it pop up?

If you want it to appear directly into a Player’s inventory, you need to set the Parent to the Backpack.

burger.Parent = Player.Backpack

By putting it in the StarterPack, a Character must respawn before they will receive the Tool.

2 Likes

The issue here is that you’re parenting the burger into the StarterPack. The StarterPack is basically a service that clones everything within it into the backpack of a player. If you’re going to make it so that the tool is given to the player, you have to do something like this:
burger.Parent = Player.Backpack

Alright, I will test this out. Thank you

Wait, would I have to make a variable for “player”. Because I tested and it says , Unknown global

Yes. Also, is this a LocalScript or a normal Script?

This is embedded into a regular script.

So I would do something like

-- local player2 = Player.Backpack
local burger = game.ServerStorage.Burger:Clone()
burger.Parent = player

Like this?

You’re forgetting the actual player variable.

local player = game:GetService("Players").LocalPlayer
local burger = game.ServerStorage.Burger:Clone()
burger.Parent = player.Backpack

Either way, this script won’t work because this is in a normal Script, and normal scripts can’t access LocalPlayer (unless they are given a variable who’s value is said player, then it would work technically.

You’re gonna have to make a RemoteEvent for this.

So the remote event would have to fire for all clients?
And how would I implement in to the script?

and I am guessing the Local script would place into StarterCharacterScripts?

No, you’re going to have to make a RemoteEvent, and make that RemoteEvent fire with RemoteEvent:FireServer().

local giveTool --Make this variable's value the RemoteEvent

giveTool.OnServerEvent:Connect(function(Player)
    local Burger = game:GetService("ServerStorage").Burger:Clone()
    Burger.Parent = Player.Backpack
end)

Essentially, you’re gonna create a script in something like ServerScriptService, and this is the script used. This will fire onto the server, which in turn will replicate to all players.

You can fire the RemoteEvent on a LocalScript by using giveTool:FireServer(). We don’t need to fill in the “Player” argument because RemoteEvents give it by default.

Ok, I understand, but the script is working, but it is not showing in my inventory. And it isnt even showing in the explorer window under starterpack .Do I have to make it a local script?

And how do I make it so it works at a certain point in time?

Here is the script but with a little amend.

local giveTool = game.ReplicatedStorage.GiveItem
	giveTool.OnServerEvent:Connect(function(Player)
    local Burger2 = game:GetService("ServerStorage").Burger2:Clone()
    Burger2.Parent = Player.Backpack
	end)

Dont I need to add FireAllClients() or should I leave it since the OnServerEvent is already present?

Do not use FireAllClients. Just use FireServer.
It’s not supposed to show in StarterPack either, like I said, StarterPack is a service that clones everything within it into the Backpack of a Player.

If you want to make it so it fires at a certain time, just use your code as normal and just use game:GetService("ReplicatedStorage").GiveItem:FireServer() in your LocalScript’s code. Where are you firing the RemoteEvent?

I am firing the remote event from a regular script in serverscriptservice

You’re supposed to do it from a LocalScript, otherwise it won’t work.

What are you even trying to achieve exactly?

I am trying to make it so that players can get to eat at a certain point in my game. But the local script will still be placed into serverscriptservice right?

If you’re gonna make it so that all players can eat a certain point in the game, then just ditch the entire RemoteEvent approach. Just do a loop and clone the Tool into the players backpacks.

for i,v in pairs(game:GetService("Players"):GetPlayers()) do
   local newBurger = game:GetService("ServerStorage").Burger:Clone()
   newBurger.Parent = v.Backpack
end

Also, LocalScripts can’t function in ServerScriptService. Only ModuleScripts and Scripts can.

So, then this would be placed into StarterCharacterScripts I presume?

This will be placed in a script in ServerScriptService. Not StarterCharacterScripts.

Ok, now it works. Now, I got an understanding for this. Thank you so much for the help.