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

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

Asked by
L30N_C 27
4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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.

0
Doesn't work... L30N_C 27 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Couldn't you just make a module script saying

script.Disabled = true
0
Oke but where do i put the module script?? L30N_C 27 — 4y
Log in to vote
0
Answered by 4 years ago

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)
0
Doesn't work.... L30N_C 27 — 4y
Log in to vote
-1
Answered by
MattVSNNL 620 Moderation Voter
4 years ago
Edited 4 years ago

Try this

game.Workspace.Script.Disabled = true

0
Sorry Enabled isn't a property of Instance Script Dalamix 26 — 4y
0
yeah xD L30N_C 27 — 4y
0
Oh MattVSNNL 620 — 4y

Answer this question