This weird glitch happens when I store an item in a slot; I can’t really explain the glitch so here’s a video of it:
Here’s the script:
local plrs = game:GetService("Players")
local tween = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.7)
local GUI = script.Parent
local plr = plrs.LocalPlayer or plrs.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local inventory = plr:WaitForChild("Backpack")
local mouse = plr:GetMouse()
local connection
mouse.KeyDown:Connect(function(key)
if key == "m" then
print("Pressed M.")
GUI.Enabled = not GUI.Enabled
end
end)
for _,v in pairs(GUI:GetChildren()) do
if v:IsA("TextButton") then
print("TextButton found: " .. v.Name)
v.MouseEnter:Connect(function()
local tweenTrack = tween:Create(v,tweenInfo,{["Size"] = UDim2.new(0,166,0,125)})
tweenTrack:Play()
v.MouseLeave:Connect(function()
local newTweenTrack = tween:Create(v,tweenInfo,{["Size"] = UDim2.new(0, 148, 0, 108)})
newTweenTrack:Play()
end)
v.MouseButton1Click:Connect(function()
for _,tools in pairs(char:GetChildren()) do
if tools:IsA("Tool") then
print("Tool equipped: Mouse clicked.")
tools.Parent = game:GetService("ReplicatedStorage")
v.Text = tools.Name
v.MouseButton1Click:Connect(function()
if tools.Parent == game:GetService("ReplicatedStorage") then
tools.Parent = inventory
v.Text = v.Name
end
end)
end
end
end)
end)
end
end