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

How would i make it so when a player joins, they auto equip a weapon?

Asked by 4 years ago

I need it so that if a player spawns they auto equip a weapon. (I'm new to scripting, so can you put the entire script, and where to put it) Currently to hide back pack i'm using this script

local CoreGui = game:GetService("StarterGui")

CoreGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) 
CoreGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false) 
0
There is no "easy" way to do this. Unfortunately, if you disable the backpack, then the tools won't work. I'm assuming you want the weapon to automatically give to the player without the tool being visible to the player's toolbar. In order to do something like this, you'd have to create a custom backpack. Lilycover87 8 — 4y
0
To do that you don't need any script if you are making a wepon put it in starter pack if u got a wepon from the toolbox just press it and make sure its in starter pack. So when a player spawns with it they will auto equip the weapon. Xxgamerrobllox3 -23 — 4y

2 answers

Log in to vote
0
Answered by
lolzmac 207 Moderation Voter
4 years ago
Edited 4 years ago

You're disabling the backpack, but luckily the tool still exists within the player's backpack and we can equip it using the EquipTool method. The tool still won't show as equipped since the toolbar is disabled, but it will be equipped. You can do this from either the server or the client, but I will be demonstrating the client-side implementation. For most convenience I recommend this localscript to be in StarterCharacterScripts, which will run every time the character is added.

local Players = game:GetService("Players")

local Character = script.Parent
local LocalPlayer = Players.LocalPlayer
local Backpack = LocalPlayer.Backpack
--At this point in time you can define a tool variable to be equipped.
local Tool = Backpack:FindFirstChild("testTool")

if Tool then
    Character:WaitForChild("Humanoid"):EquipTool(Tool)
    --Equip the tool
end
0
thanks, really helped! siasiman2 3 — 4y
Ad
Log in to vote
1
Answered by
marfit 104
4 years ago

```lua game.Players.PlayerAdded:Connect(function(Player) --Tool will be used here without reference. Just assign Tool or whatever variable you need.

Player.CharacterAdded:Connect(function(Character)
    Character:WaitForChild("Humanoid"):EquipTool(Tool)
end)

end)
``` This code will equip whatever tool you assign to the Tool variable whenever the player's character is created.

Answer this question