Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to enable a script in workspace from a localscript?

Asked by 2 years ago
Edited 2 years ago

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.

0
After some testing, I realized that scripts don't deactivate necessarily when you disable them in game. I found another solution to my problem. ThePeaceTaco 5 — 2y

1 answer

Log in to vote
0
Answered by
extrorobo 104
2 years ago

copy the script, create a new script in workspace, paste the script that you copied from you local script, and boom. your done.

I hope this helped, if you have anymore questions you can message me on roblox

Ad

Answer this question