Yes!
To start off, let's make a mobile button that prints "Clicked" and has all the essential variables/properties.
Code:
local ContextActionService = game:GetService("ContextActionService")
local function Drop(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
print("Clicked")
end
end
ContextActionService:BindAction("Interact", collectTreasure, true, Enum.KeyCode.T, Enum.KeyCode.ButtonR1)
ContextActionService:SetPosition("Interact", UDim2.new(1, -70, 0, 10))
ContextActionService:SetImage("Interact", "rbxassetid://0123456789")
Okay, once we do that, let's make it detect if a player is holding an item and make it drop.
function CHECK_TOOL(character)
for _, v in pairs(character:GetChildren()) do
if v:IsA("Tool") then
print("tool found!")
return v
end
end
end
Now, let's combine the codes.
local ContextActionService = game:GetService("ContextActionService")
local function Drop(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
print("Clicked")
local Character = game.Players.LocalPlayer.Character
function CHECK_TOOL(character)
for _, v in pairs(character:GetChildren()) do
if v:IsA("Tool") then
print("tool found!")
return v
end
end
end
end
end
local v = Drop(game.Players.LocalPlayer.Character)
v.Parent = workspace
v.Position = character.Position
ContextActionService:BindAction("Interact", collectTreasure, true, Enum.KeyCode.T, Enum.KeyCode.ButtonR1)
ContextActionService:SetPosition("Interact", UDim2.new(1, -70, 0, 10))
ContextActionService:SetImage("Interact", "rbxassetid://0123456789")
btw, I didn't script to pick up because when you hit the tool, (step on) it automatically picks it up
9 comments
don't give the script
why?
bruh whyd you downvote for sending a code
Thanks, I'll test it out tomorrow and experiment. :)
if it works please upvote and accept answer ty!
if it works please upvote and accept answer ty!
Don’t worry I will upvote it, idky leamir downvoted it
same
ty