Basically what this script does is it allows the player to drop an item from their inventory. It is a local script so when the player drops the item they’re the only one to see it(Unimportant). When I click on an item in my inventory then click another item in my inventory then I drop that item, the first item i clicked on drops as well. I’m not sure how to fix this. I tried using coroutine.yield()
but it didn’t work for me. Also another important thing to note, which was idiotic of me is that this script is copy and pasted into other the slots.
clip of the problem, no errors in output
https://medal.tv/games/roblox-studio/clips/aTDR9IAnYwDp_/d1337Z4wbtGX?invite=cr-MSxRSlMsMjQ5MTMwNTks
script in textbutton, local script.
local text
local click = 0
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
script.Parent.Visible = false
wait(2)
local imgframe = script.Parent
script.Parent.Item.Changed:Connect(function(item)
if item == "empty" then
script.Parent.Visible = false
imgframe.Image = "0"
script.Parent.Item.Value = "empty"
script.Parent.Parent.Parent.items:FindFirstChild(script.Parent.Name)
elseif item == "Wood" then
imgframe.Image = "rbxassetid://8812775718"
script.Parent.Visible = true
local wood = Instance.new("StringValue")
wood.Name = script.Parent.Name
wood.Value = "Wood"
wood.Parent = script.Parent.Parent.Parent.items
text = "A hardy and chunky piece of wood."
elseif item == "Fiber" then
imgframe.Image = "rbxassetid://8812843259"
script.Parent.Visible = true
local fiber = Instance.new("StringValue")
fiber.Name = script.Parent.Name
fiber.Value = "Fiber"
fiber.Parent = script.Parent.Parent.Parent.items
text = "A strand of fiber."
elseif item == "Rock" then
imgframe.Image = "rbxassetid://8812849092"
script.Parent.Visible = true
local Rock = Instance.new("StringValue")
Rock.Name = script.Parent.Name
Rock.Value = "Rock"
Rock.Parent = script.Parent.Parent.Parent.items
text = "A rough Rock."
end
end)
script.Parent.Activated:Connect(function()
script.Parent.Parent.Parent.aboit.Text = text
script.Parent.Parent.Parent.Drop.Visible = true
script.Parent.Parent.Parent.Drop.drop.Activated:Connect(function() -- problem down here
local humc = player.Character.HumanoidRootPart.CFrame
local offset = CFrame.new(0, 0, -2)
local org = game.ReplicatedStorage:FindFirstChild(script.Parent.Item.Value)
local copy = org:Clone()
copy.Parent = game.Workspace
copy.CFrame = humc*offset
script.Parent.Item.Value = "empty"
script.Parent.Parent.Parent.Drop.Visible = false
script.Parent.Parent.Parent.aboit.Text = ""
end)
end)
I don’t think this script is that important to the solution but I’ll give it as well. This is a local script inside of starter character scrips
local char = script.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local UIS = game:GetService("UserInputService")
local inventory = player.PlayerGui.Inventory
local slots = inventory.Invemtory.Slots
local mouse = player:GetMouse()
local HumanoidRootPart = char.HumanoidRootPart
local debounce = false
wait(2.1)
local one = slots.one.Item
local two = slots.two.Item
local three = slots.three.Item
local four = slots.four.Item
local five = slots.five.Item
local six = slots.six.Item
local seven = slots.seven.Item
local eight = slots.eight.Item
local nine = slots.nine.Item
local ten = slots.ten.Item
local eleven = slots.eleven.Item
local twelve = slots.twelve.Item
local thirteen = slots.thirteen.Item
local fourteen = slots.fourteen.Item
local fifteen = slots.fifteen.Item
UIS.InputChanged:Connect(function()
if mouse.Target then
debounce = false
if mouse.Target:FindFirstChild('Pickable') then
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.E then
local Magnitude = (HumanoidRootPart.Position - mouse.Hit.Position).Magnitude
if Magnitude <= 10 then
if mouse.Target:FindFirstChild('Pickable') then
if debounce == false then
debounce = true
if one.Value == "empty" then
one.Value = mouse.Target.Name
mouse.Target:Remove()
elseif two.Value == "empty" then
two.Value = mouse.Target.Name
mouse.Target:Remove()
elseif three.Value == "empty" then
three.Value = mouse.Target.Name
mouse.Target:Remove()
elseif four.Value == "empty" then
slots.four.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif five.Value == "empty" then
slots.five.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif six.Value == "empty" then
slots.six.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif seven.Value == "empty" then
slots.seven.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif eight.Value == "empty" then
slots.eight.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif nine.Value == "empty" then
slots.nine.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif ten.Value == "empty" then
slots.ten.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif eleven.Value == "empty" then
slots.eleven.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif twelve.Value == "empty" then
slots.twelve.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif thirteen.Value == "empty" then
slots.thirteen.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif fourteen.Value == "empty" then
slots.fourteen.Item.Value = mouse.Target.Name
mouse.Target:Remove()
elseif fifteen.Value == "empty" then
slots.fifteen.Item.Value = mouse.Target.Name
mouse.Target:Remove()
else
slots.Parent.Parent.Parent.Fullinv.Enabled = true
wait(2)
slots.Parent.Parent.Parent.Fullinv.Enabled = false
end
end
end
end
end
end)
end
end
end)
wait()
mouse.Target.Changed:Connect(function()
debounce = false
end)
As you can see I’m very bad at scripting so if you guys can give me some tips as well that would be great but you don’t have to, thank you for your time.