Getting any errors first of all?
No error in relation with this script
What exactly is happening when you try to drop?
Nothing x)
Just the imagebutton color change
What’s your OnServerEvent code right now?
game.ReplicatedStorage.DropEvent.OnServerEvent:Connect(function(player)
local t =player.Character:FindFirctChildWhichIsA("Tool")
local humanoid = player.Character:FindFirstChild("Humanoid")
humanoid:UnequipTools()
t.Parent = workspace
t.Position = player.Character.HumanoidRootPart.Position
end)
Try this perhaps?
game.ReplicatedStorage.DropEvent.OnServerEvent:Connect(function(player, tool)
local char = player.Character
local t = char:FindFirctChildWhichIsA("Tool")
local humanoid = char:FindFirstChild("Humanoid")
print(t, humanoid)
humanoid:UnequipTools()
if t then
t.Parent = workspace
t.Position = player.Character.HumanoidRootPart.Position
elseif tool then
tool.Parent = workspace
tool.Position = player.Character.HumanoidRootPart.Position
end
end)
You can now specify a tool to drop it if you’re not holding one, were you trying ti when the tool was unequipped or equipped?
It’s the same result. Maybe it come from the local script :
local equipped = script.Parent.Handler.Equipped
local selected = script.Parent.Handler.Selected
local location = script.Parent.Handler.Location
local player = game.Players.LocalPlayer
local character = player.Character
local items = {}
local buttons = {}
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false) -- Makes the original backpack gui invisible
function search(location)
for i,v in pairs(location:GetChildren()) do -- Find all item in a specific location
if v:isA("Tool") and #items <= 8 then -- If the item found is a "Tool"
table.insert(items,v) -- We're going to put all the tools found in a table.
print("1")
end
end
end
function refresh()
search(location)
for i,v in pairs(buttons) do -- Finds all items in the table
v:Destroy() -- Destroy 'em all
print("2")
end
for i,v in pairs(items) do -- Finds all items in the table
local button = script.Sample:Clone() -- clones the sample button inside the localscript
button.Name = v.Name -- sets the cloned button's name to the name of the item
button.LayoutOrder = i
button.Parent = script.Parent.Handler -- Sets the parent of the cloned button to the handler
button.Image = v.TextureId -- Sets the image of the button to the texture id of the tool
table.insert(buttons,button) -- Inserts the button to our table "buttons"
print("3")
local userInput = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local dropEvent = ReplicatedStorage:WaitForChild('DropEvent')
local function drop(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
local keycode = input.KeyCode
button.MouseButton2Click:Connect(function()
game.ReplicatedStorage.DropEvent:FireServer()
end)
end
end
end
button.MouseButton1Click:connect(function()
print("4")
if script.Parent.Handler.Selected.Value == nil or script.Parent.Handler.Selected.Value ~= v then -- Checks if the selected value is nothing or if the selected value is not the button
script.Parent.Frame.ItemName.Text = v.Name -- Sets the TextLabel's Text to the name of the tool/button
script.Parent.Frame.ImageLabel.Image = v.TextureId -- Sets the image label's image to the texture id of the tool
script.Parent.Handler.Selected.Value = v
print("5")
if equipped.Value == nil or equipped.Value ~= selected.Value then -- Just the same as the last one
character.Humanoid:UnequipTools() -- Forces the player to unequip the tool that they equipped
print("6")
character.Humanoid:EquipTool(selected.Value)
equipped.Value = selected.Value
print('7')
end
else
character.Humanoid:UnequipTools() -- Forces the player to unequip the tool that they equipped
script.Parent.Handler.Selected.Value = nil
script.Parent.Frame.ItemName.Text = "Name"
equipped.Value = nil
end
end)
end
end
function backpackRefresh()
print("8")
items = {}
search(character)
search(player.Backpack)
refresh()
end
backpackRefresh()
player.Backpack.ChildAdded:connect(backpackRefresh)
player.Backpack.ChildRemoved:connect(backpackRefresh)
search(location)
backpackRefresh()
backpackRefresh()
Why did you put it in this?I dont even see anything that uses this function?? Why did you put this in here when it worked fine just as a standalone event?
What th-?
I don’t remember doing that… We’re nearly 4 on the same place so maybe it’s someone else…
That explains why the code did not work since nothing even uses the drop function, how is someone able to edit your code when you’re editing it? Did you close out of the script?
I closed it since I’m working on my SCP-914 too
– Edit –
So the code runs, but it seems that the ttol isn’t correctly removed. Imma show a record
Here is the record
https://cdn.discordapp.com/attachments/782594725274189864/824019475648217158/Black_Albis_Place_Number__14_-_Roblox_Studio_2021-03-23_21-38-42.mp4
Perhaps change this to
t.CFrame = player.Character.HumanoidRootPart.CFrame.LookVector * 5
Same result as earlier, shown in the record
I think you could remove that line then since it’ll unequip it infront of you
I think I found why :
– Edit –
Nvm
local t = char:FindFirctChildWhichIsA("Tool")
Maybe try
t.CFrame = player.Character.HumanoidRootPart.CFrame.LookVector * -5
Oh I found why, I forgot to delete the button, so it was still linked to the player inventory
button.MouseButton2Click:Connect(function()
game.ReplicatedStorage.DropEvent:FireServer()
button:Destroy()
end)
Ohhh haha! Is it working as intended now?