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

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

Asked by
tjtorin 172
7 years ago
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?

0
Your script does not look correct. crywink 419 — 7y
0
Simply ensure this code is a LocalScript, and place the tool in StarterPack, it should work I'd hope. M39a9am3R 3210 — 7y

2 answers

Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago

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
Ad
Log in to vote
0
Answered by 7 years ago

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.

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 tjtorin 172 — 7y

Answer this question