Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to enable a script in workspace from a localscript?

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

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.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.