Trying to enable OTS when you hold right button help

  1. What is the issue?
    I have this script but the OTS enables when it is equipped, I want to try and make it when it’s equipped and when you hold the right mouse button, and disable if it’s unequipped or you don’t hold the right mouse button down anymore.

  2. What solutions have you tried so far?
    I tried to use MouseButton2Down and up to enable OTS but it does it even if the tool is unequipped. Tried looking for solutions but cant find any.

Here’s the code.

Thank you!

When a roblox tool is equipped, it gets parented under the player’s character
Simply you can create an if statement to detect that

Something along these lines:

local mouse = player:GetMouse()
local tool = script.Parent 
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

    if tool.Parent ~= character then return end -- guard clause

    if tool.Parent ~= character then return end

    ots:Disable() -- if you want OTS to disable once the player unequipes

Also side note you’ll get faster responses if you use the proper category #help-and-feedback:scripting-support rather than #help-and-feedback:platform-usage-support :slight_smile: