How do i make a spawning flashlight?

So i made a flashlight, and been wondering how do i make it spawn with you cause my game backpack is disabled.
image

4 Likes

You can use [Flashlight here]:Clone() to clone the flashlight. You will need to parent this to the player’s StarterGear if you want them to spawn with the flashlight at all times.

4 Likes

the flashlight is in Starterpack so i create a local script and wrote Flashlight:Clone()

3 Likes

You want to make this script outside of Starterpack, if it’s inside the gear inside Starterpack, the script inside it will not work.

3 Likes

So, i have to put it in workspace?

2 Likes

e.obj (92.3 KB)

2 Likes

wrong post, so sorry


e
eeee

2 Likes

If it’s a script, Workspace could work, but preferably ServerScriptService. If it’s a local script, you should put it in StarterPlayerScripts

2 Likes

Thanks, where do i put the gear?

2 Likes

script.Flashlight:Clone() would work?

2 Likes

The cloning script should be outside of the flashlight gear in order for it to work.

3 Likes
game.Starterplayerscripts.Flashlight:Clone()
2 Likes

@Dragonfable6000 the gear is on starterplayer and the script is on workspace and the code is: game.StarterPlayer.StarterPlayerScripts.Flashlight:Clone()
it will duplicate it but in starterplayer

1 Like

Generally if you want to clone something that doesn’t exist in the game, you should have the flashlight be in ReplicatedStorage

1 Like

The flashlight stuff.


backpack coregui is disabled and the player spawns with it on the hand.


the script is on workspace the flashlight is on replicated storage


the code is game.ReplicatedStorage.Flashlight:Clone()


1 Like

All tools in starterpack go to the players backpack, you can just do use the Players.PlayerAdded, wait for the tool to get cloned into the backpack and move it into the character or use Humanoid:EquipTool(player.Backpack.Flashlight)
Should look something like this.

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
   local backpack = player.Backpack
   repeat task.wait() until backpack:FindFirstChild("Flashlight")
   local character = player.Character or player.CharacterAdded:Wait()
   backpack.Flashlight.Parent = character
end)

can be placed in serverscriptservice

Where does the flashlight has to be placed?

The flashlight can be placed in StarterPack

Alright thank you, if it works ill give you a solution.

sorry for bumping, but I recommend using a variable to clone the flashlight, you might encounter some issues when trying certain things