Clicking on a tool

Hey Scripters from Roblox!

I wanted to know what script or something more to make a sword (tool) that people can click and the sword stills there

Here’s a example of what I’m saying:

If y’all played a game made by Rdite called “Flex Your Age Account”, you can see that there’s a underground place where you can PVP people. You click in the sword and they still continue to stay in there specific area.

And I’m making a game where I want people to PVP and with the example that I showed to you guys but I don’t know what script I need to use and If there’s something that I need to also include as well. Can you guys help me?

Thanks!

  • Juan
1 Like

Click Detectors allow you to run code when clicked. Investigate them here.

The Flex Your Account Age fencing sword giver is just a ClickDetector put into an invisible barrier around the swords.

Here’s an API reference that will help you achieve your goal.

Add a click detector in that sword and then put the sword in replicated storage and type the following code:

local ClickDetector = script.Parent.ClickDetector
local sword = game.ReplicatedStorage:FindFirstChild("Sword")

ClickDetector.MouseClick:Connect(function(plr)
    sword:Clone().Parent = game.Players[plr.Name].Backpack
end)

NOTE: Make sure sword is a tool, not a model.

Short script:

local CD = script.Parent.ClickDetector
local Sword = game.ReplicatedStorage:WaitForChild("Sword")

CD.MouseClick:Connect(function(Player)
    sword:Clone().Parent = Player.Backpack
end)

It should work? Let me record a gif.

And its not short script at all? you just copied my way and just change plr.Name

instead to plr object?

Okay, let’s stop this discussion, this is off topic.