Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can a tool give you another tool when enabled?

Asked by 9 years ago

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

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

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.

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 cooldrewbie 94 — 9y
0
That is not something that would result from this solution unless you are having a different problem. 1waffle1 2908 — 9y
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 cooldrewbie 94 — 9y
0
Then your problem is about writing a sword that does that and has nothing to do with ClickDetectors. 1waffle1 2908 — 9y
Ad

Answer this question