I want to make a weapon tool, where if you press “R” while its equipped, it does some type of special move (I want multiple like moves for R, T, Y, U, ect.) how do i go about this?
Look into ContextActionService for stuff like this.
make a module in the tool with all the abilities as function ( module.R = function() )
send inputs to server (with remote event)
if input is R then module.R(character)
jus an example
Maybe you can try
local tool = --define the tool
tool.equiped:Connect(function()
userInput.InputBegan:Connect(function(input,gameProcessed)
if gameProccessed then
if input.KeyCode == Enum.KeyCode.Q then
-- There you can write what u want to do when press the Q
end
end
end)
end)
in the game im currently working you can control every aspect of the weapon with different keys just how you say you want it, i used InputService to detect which key is pressed and then check if the Tool is currently inside of players character (if it is that means it must be equipped) then i execute the code i need along side the logic.
Important!
Make sure anything other than visuals is done ON THE SERVER that will prevent exploiters from cheating. i personally do a double check where i check if player can do the action on the client if it succeds send remote event to server and then the server checks a second time to verify.
Example Code – put in local script
local UserInputService = game:GetService("UserInputService")
local Tool = script.Parent
local key = "E"
UserInputService.InputBegan:Connect(function(info)
if info.KeyCode == Enum.KeyCode[key] then
if Character:FindFirstChild(Tool.Name) then
--Do code or send a remote event to server
end
end
end)