First this is the script (Local Script)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
script.Parent.MouseButton1Click:Connect(function()
player.PlayerScripts.RightScript.Disabled = false
end)
-
What do you want to achieve? Make RightScript Disabled false if player hold the button and make it true if player unhold the button
-
What is the issue? There is not MouseHoldClick function on Roblox Studio
-
What solutions have you thought of so far? Searching on YouTube if there is a way to make MouseHoldClick but I don’t saw anything + I saw some videos but I didn’t understand
2 Likes
There are events MouseButton1Down and MouseButton1Up. They detect whether the button is being pressed or when the button is released.
Use MouseButton1Down to detect when the button is being pressed, and use MouseButton1Up to detect when the button was released.
Here is your script:
local player = game.Players.LocalPlayer
local PlayerScripts = player:WaitForChild("PlayerScripts")
local Button = script.Parent
Button.MouseButton1Down:Connect(function() -- when button is being held down
PlayerScripts.RightScript.Disabled = false -- makes 'RightScript' enabled
end)
Button.MouseButton1Up:Connect(function() -- when button is let go
PlayerScripts.RightScript.Disabled = true -- disables the 'RightScript'
end)
Edit: Oops I put PlayerGui instead of PlayerScripts, my bad. Just fixed it.
1 Like
tysm bro that work tysm thank you for helping me you the only who replay for my topic thank you so much
1 Like
You are very welcome! Really happy to help!
1 Like