I am making a custom tool pack and am trying to make when a weapon is picked up it goes into the first empty slot. When I pick up one weapon it goes into the first slot but when I pick up the second it also goes into the first slot even thought the value has changed to two. I have programmed the script to check for the value of the variable but it is still staying as one.

This is the script I used to find out what the value is but it prints out 1 when it should print out 2 after I pick up the first weapon:

This is in a normal script inside of the value.

while true do
	print(script.Parent.Value)
	wait(1)
end

And this is the local script inside of the pick up GUI:

local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer
local uis = game:GetService("UserInputService")
local Mouse = Player:GetMouse()
local character = Player.Character

local ActiveParts = workspace:WaitForChild("Weapons")
nextslot = character:WaitForChild("weapons").nextslot.Value



local Tag = script.Parent



RunService.RenderStepped:connect(function()
    local Target = Mouse.Target
    if Target and ActiveParts:IsAncestorOf(Target) then
        Tag.Visible = true
	uis.InputBegan:connect(function(input)
		if input.KeyCode == Enum.KeyCode.E then
			local children = workspace.Weapons:GetChildren()
				for i, child in ipairs(children) do
					Target.Parent.Parent = character.weapons.backpack:FindFirstChild("slot"..nextslot)
					script.Parent.Parent.Parent.Items:FindFirstChild(nextslot).hasitem.Value = true
			end
		

	

    else

        Tag.Visible = false

		    end 
		
	end)
	end
    Tag.Position = UDim2.new(0,Mouse.X-Tag.AbsoluteSize.X,0,Mouse.Y-Tag.AbsoluteSize.Y)



end)

Help would be appreciated.

4 comments

0

Is your "nextslot" variable not updating?

0

The actual nextslot value that the variable is set to equal is updating but in the script it apparently isn't.

0

wont script.Parent.Parent.Parent.Items:FindFirstChild(nextslot).hasitem.Value = true throw an error? since nextslot is a number? unless the name of the intvalue is equal to its value

0

No it doesn't give an error.