I got very strange error

Basically a function in one place changes a variable after the other place is not changed (that variable is a global variable), you can download the map to view
The wrong module script is at StarterPlayer.StarterPlayerScripts.LocalMain.ToolBarMain.Main

Map:
Minecraft Java Edition(Beta).rbxl (194.1 KB)

I’ve been stuck with this error for a long time
Can someone help me?

1 Like

The AA variable is the one I forgot to delete

You’ll know what’s wrong when you try to run and play, click on the grass block and then click on the inventory (the first one)

local UserInputService = game:GetService("UserInputService")
local LocalizationService = game:GetService("LocalizationService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local LocalPlayer = game.Players.LocalPlayer

local GameSetting = require(ReplicatedStorage.GameSetting)

local RobloxLocaleId = LocalizationService.RobloxLocaleId

local ToolBar
repeat
	ToolBar = LocalPlayer.PlayerGui:WaitForChild("ToolBar")
until ToolBar
local Gui
repeat
	Gui = LocalPlayer.PlayerGui:WaitForChild("InventoryGui")
until Gui

local SelectPos = 0
local Select = 1
local InventoryId = {
	["1"] = "minecraft:air",
	["2"] = "minecraft:air",
	["3"] = "minecraft:air",
	["4"] = "minecraft:air",
	["5"] = "minecraft:air",
	["6"] = "minecraft:air",
	["7"] = "minecraft:air",
	["8"] = "minecraft:air",
	["9"] = "minecraft:air"
}

function Re(A, SelectSort)
	InventoryId[tostring(SelectSort)] = A
end

function WhileLoop()
	coroutine.resume(coroutine.create(function()
		while true do
			wait()
			
			ToolBar.Base.SelectItem.Position = UDim2.fromOffset(SelectPos, -1)
			
			for _, A in pairs(ToolBar.Base.Select:GetDescendants()) do
				if A.Parent == ToolBar.Base.Select and A:IsA("Frame") then
					if A.Base:WaitForChild("ViewportFrame"):FindFirstChild("Block") then
						A.Base.ViewportFrame.Block:Destroy()
					end
				end
			end
			
			for A, B in pairs(InventoryId) do
				local SelectBlockId = string.split(B, ":")[2]
				
				if SelectBlockId ~= "air" then
					local CloneBlock = GameSetting.FixedProperties.Blocks[SelectBlockId].Block:Clone()
					CloneBlock.Parent = ToolBar.Base.Select["Select" .. A].Base.ViewportFrame
					CloneBlock.Name = "Block"

					for _, B in pairs(GameSetting.FixedProperties.Blocks[SelectBlockId].Texture:GetDescendants()) do
						local CloneTexture = B:Clone()
						CloneTexture.Parent = CloneBlock
					end
				end
			end
			
			print(InventoryId["1"])
			print(AA)
		end
	end))
end

local TextLabelTween = TweenService:Create(ToolBar.ItemName, TweenInfo.new(1), {
	TextTransparency = 1
})

function Event()
	UserInputService.InputEnded:Connect(function(Object, GameProcessedEvent)
		if GameProcessedEvent then
			return
		end

		if Object.UserInputType == Enum.UserInputType.Keyboard then
			if Object.KeyCode.Name == "E" then
				Gui.Base.Visible = not Gui.Base.Visible
			end
		end
	end)
	
	UserInputService.InputChanged:Connect(function(Type)
		if Type.UserInputType == Enum.UserInputType.MouseWheel then
			if Type.Position.Z == 1 then
				SelectPos += 45
				Select += 1
				
				if SelectPos > 360 then
					SelectPos = 0
					Select = 1
				end
			elseif Type.Position.Z == -1 then
				SelectPos -= 45
				Select -= 1
				
				if SelectPos <= -45 then
					SelectPos = 360
					Select = 9
				end
			end

			ToolBar.ItemName.TextTransparency = 0
			TextLabelTween:Cancel()
			
			local SelectBlockId = string.split(InventoryId[tostring(Select)], ":")[2]
			
			if SelectBlockId == "air" then
				ToolBar.ItemName.Text = ""
				return
			end
			
			local DisplayName = GameSetting.FixedProperties.Blocks[SelectBlockId].DisplayName
			
			for i, v in pairs(DisplayName) do
				if i == RobloxLocaleId then
					ToolBar.ItemName.Text = v
					break
				end
			end
			
			wait(2)
			
			TextLabelTween:Play()
		end
	end)
	
	UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
		if GameProcessedEvent then
			return
		end
		
		if Input.UserInputType == Enum.UserInputType.Keyboard then
			if Input.KeyCode == Enum.KeyCode.One then
				Select = 1
				SelectPos = 0
			elseif Input.KeyCode == Enum.KeyCode.Two then
				Select = 2
				SelectPos = 45
			elseif Input.KeyCode == Enum.KeyCode.Three then
				Select = 3
				SelectPos = 90
			elseif Input.KeyCode == Enum.KeyCode.Four then
				Select = 4
				SelectPos = 135
			elseif Input.KeyCode == Enum.KeyCode.Five then
				Select = 5
				SelectPos = 180
			elseif Input.KeyCode == Enum.KeyCode.Six then
				Select = 6
				SelectPos = 225
			elseif Input.KeyCode == Enum.KeyCode.Seven then
				Select = 7
				SelectPos = 270
			elseif Input.KeyCode == Enum.KeyCode.Eight then
				Select = 8
				SelectPos = 315
			elseif Input.KeyCode == Enum.KeyCode.Nine then
				Select = 9
				SelectPos = 360
			end
		end
	end)
end

local Item = ""

local Main = {
	Run = function()
		Event()
		WhileLoop()
		for i, v in pairs(GameSetting.FixedProperties.Blocks) do
			local Clone = script.Item:Clone()
			Clone.Parent = Gui.Base.Gui.Scrolling
			Clone.Name = i
			Clone.LayoutOrder = v.Priority

			local CloneBlock = v.Block:Clone()
			CloneBlock.Parent = Clone.Viewport

			for _, i in pairs(v.Texture:GetDescendants()) do
				local Textrue = i:Clone()
				Textrue.Parent = CloneBlock
			end

			local CloneScript = script.ClickEvent:Clone()
			CloneScript.Parent = Clone.Button
			CloneScript.Disabled = false
		end
	end,
	
	Call = function(Item_, Mode) --This function changes the variable, but nowhere else sees the variable changed
		if Mode == true then
			if Item == "" then
				Item = Item_.Parent.Parent.Name
			end
		else
			local SelectSort = string.sub(Item_.Name, #Item_.Name)
			Re("minecraft:" .. Item, SelectSort)
			print(InventoryId)
			Item = ""
		end
	end,
}

return Main

its obvious it says httprequests can only be executed by server meaning your executing it via client aka local script use remote events to execute it by server!

1 Like


that error is my game console addon

then bro what error do you have and where?

The Call function in the source code of at StarterPlayer.StarterPlayerScripts.LocalMain.ToolBarMain.Main, it is used to interact with the button script in the backpack, but the variable it changes will not be synchronized to the global, I did not use local

	Call = function(Item_, Mode) --This function changes the variable, but nowhere else sees the variable changed
		if Mode == true then
			if Item == "" then
				Item = Item_.Parent.Parent.Name
			end
		else
			local SelectSort = string.sub(Item_.Name, #Item_.Name)
			Re("minecraft:" .. Item, SelectSort)
			print(InventoryId)
			Item = ""
		end
	end,

I have tried various methods to no avail

hmm is the module being fired by a local script?

yes
All calls to it are local scripts

No wonder it gave error make it a server script would ya!

Ah, that includes the client’s inventory control system, and I’d like to be able to potentially reduce latency, how can I do that?

Only the server can issue HTTP-based requests via Roblox’s HttpService, attempting to do so on client will result in the error you’re seeing.

he did said its cause of a plugin

using task.wait() and tweenfunction to smoothly interpolate it

1 Like

I used _G to pass the variable successfully, thanks for the advice