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

[STILL UNSOLVED]How do i disable a script via a script???

So im currently scripting a menu gui. I have a camera shake script on workspace that is "disabled = false" So it plays. The only thing thoe is that i want it to be disabled when you hit play so the camera doesn't shake the whole time, just in the menu. Right now i have a mousebutton1click function, that has some code in it. Does somebody know how to disable a script in workspace with a localscript in a textbutton in startergui??

at the bottom of the script is the lines where i have tried disabling the script...

Here is the script so far:

-- Locals --

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

-- Main --

script.Parent.MouseButton1Click:Connect(function()
	game.Workspace.Glitch.Playing = true
	wait(4)
	game.Workspace.MenuSound.Playing = false
	game.Workspace.CitySound.Playing = true
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = Humanoid
	script.Parent.Visible = false
	
end)

script.Parent.MouseButton1Click:Connect(function()
	wait(4)
	game.Workspace.ScreenShake.Disabled = true
end)

4 answers

Try this:

-- Locals --

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

-- Main --

script.Parent.MouseButton1Click:Connect(function()
    game.Workspace.Glitch.Playing = true
    wait(4)
    game.Workspace.MenuSound.Playing = false
    game.Workspace.CitySound.Playing = true
    Camera.CameraType = Enum.CameraType.Custom
    Camera.CameraSubject = Humanoid
    script.Parent.Visible = false
    wait(4)
    game.Workspace.ScreenShake.Disabled = true
end)

I think that will work. If not then I would probably request some more examples of what is going on.

1 comment

0

Doesn't work...

Couldn't you just make a module script saying

script.Disabled = true

1 comment

0

Oke but where do i put the module script??

I believe you can't use a local script so you should use a Remote Event so

In the local script:

script.Parent.MouseButton1Click:Connect(function()
	game.Workspace.RemoteEvent:FireServer()
end)

then add a script in the Remote Event and put this in the script:

script.Parent.OnServerEvent:Connect(function()
	game.Workspace.Script.Disabled = true
end)

1 comment

0

Doesn't work....

Try this

game.Workspace.Script.Disabled = true

3 comments

0

Sorry Enabled isn't a property of Instance Script

0

yeah xD

0

Oh

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