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
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
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.
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?
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 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.