Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I am trying to use an auto equip script for my weapon but it only works in studio?

local tool = script.Parent
local ply = game.Players.LocalPlayer
local character = ply.Character
if not character or not character.Parent then
    character = ply.CharacterAdded:wait()
end
tool.Parent = character

The script above is a child of my gun and the gun auto equips in studio but not in the game can someone please tell me how to fix this?

2 comments

0

Your script does not look correct.

0

Simply ensure this code is a LocalScript, and place the tool in StarterPack, it should work I'd hope.

2 answers

✓ Accepted answer

Make a local script and put this script here. Also put this script in the tool which you are using, which in your case is in the gun.

wait()
EnableBackpackGui = false -- false disables Backpack gui, true enables it.
Weapon = script.Parent.Name
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse();
local char = player.Character
local tool = player.Backpack:FindFirstChild(""..Weapon.."")
db=1
while wait() do
if char then
game.StarterGui:SetCoreGuiEnabled(2,EnableBackpackGui)
for i,v in ipairs(char:GetChildren()) do
if v.className ~= ""..Weapon.."" then
wait()
if db == 1 then
player.Character.Humanoid:EquipTool(tool)
db=2
end
end
end
script.Parent.Unequipped:connect(function()
db=1
end)
end
end

Just put the tool inside "StarterPack" nothing else, You don't need a script just simply drag the tool in the "StarterPack" then it will work.

1 comment

0

It does not auto equip when I do that and I am hiding the backpack so they would not be able to choose it if I don't have an auto equip

This discussion is preserved as it was. New answers, comments, and votes are closed.