How can I change this to if the player has a certain tool equipped then he can press e.
2 Likes
When a tool is equipped it automatically goes to the player’s character you could just check inside of the character using :FindFirstChildOfClass
and then put in Tool and it’ll return the first tool it finds which is the one that is equipped then you have access to it’s name property
local UIS = game:GetService("UserInputService")
local Client = game.Players.LocalPlayer
UIS.InputBegan:Connect(function(Input)
local Character = Client.Character
if not Character then return end
local Tool = Character:FindFirstChildWhichIsA("Tool")
if not Tool then return end
if Tool.Name == "ToolName" and Input.KeyCode == Enum.KeyCode.E then
print("Pressed E with tool",Tool.Name)
end
end)
1 Like
Yes but it should be :FindFirstChildOfClass
nope, FindFirstChildWhichIsA() works perfectly
1 Like
Oh well they basically do the same thing now that I think about it