This is a local script. It works so far as the "print" is produced when I hold down 'R'.
As well, I can destroy an item in workspace, but whenever I try to disable this script, it does not work.
It is probably obvious by my question, but I am new to scripting. I apologize for any ignorance that I obviously display here :)
Here is my code:
UserInputService = game:GetService("UserInputService")
local rKeyPressed = false
UserInputService.InputBegan:Connect(function(input,gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.R then
rKeyPressed = true
while rKeyPressed == true do
wait()
game.Workspace.Model.paint.Script1.Disabled = false
print("R Key is being held")
end
end
end)
UserInputService.InputEnded:Connect(function(input,gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.R then
rKeyPressed = false
end
end)
The only part that does not seem to work correctly is game.Workspace.Model.paint.Script1.Disabled = false The goal is for holding down R to enable the script. Later, I hope to be able to return the script to a disabled state when R is not being pressed, but first I need this to work.

1 comment
After some testing, I realized that scripts don't deactivate necessarily when you disable them in game. I found another solution to my problem.