Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can a tool give you another tool when enabled?

I'm trying to make it to where once I enable a tool It gives me a sword This script is the closest I have came to it but I need a click detector and it doesn't give me a sword when I enable it.

function hi(x)
	y = x.Backpack
	z = game.Lighting["LinkedSword"] 
	z:Clone().Parent = y
end

script.Parent.ClickDetector.MouseClick:connect(hi)

The problem with this is that I need a click detector, and when I enable the tool it doesnt give me a sword, I have to click the tool when its laying down on the ground instead. Any idea on how I could enable a tool and it will give me a sword?

1 answer

I do believe that ClickDetectors do not fire if you have anything selected. If you want to detect when a player clicks on something, regardless of what they have selected, you can use game.Players.LocalPlayer:GetMouse() to access the mouse outside of a tool, then fire a signal to a RemoteEvent to signal the server to give the player a tool, or more simply (if the game is not FilteringEnabled) just grant the tool to the player from the same script in the client.

4 comments

0

Yes that is true, I have experimented with taking the scripts out of the Roblox Game Card gear because they have the same mechanics that I'm trying to script, but My trouble is that I don't want the item or card to disappear once I click with it

0

That is not something that would result from this solution unless you are having a different problem.

0

Yea, i do not want a click detector where you can click it when not even holding it. Its like you have a sword in your hand, and to swing the sword you must click the screen, but I'm trying to script it to where once I swing the sword it gives me another sword

0

Then your problem is about writing a sword that does that and has nothing to do with ClickDetectors.

This discussion is preserved as it was. New answers, comments, and votes are closed.