Hello! Currently I’m trying to re-enable a script by using another script in-game but it doesn’t work at all. It shows as it is enabled but the script itself does nothing. One of the scripts is supposed to activate an ‘if’ statement (which is the script I’m trying to re-enable) and one of the scripts is supposed to enable that script (the other script is disabled by default).
Currently I’m trying use a method with the Remote Event. The Local Script inside the player’s PlayerGui fires that event. When the event fires, it activates the Server Script inside the ServerScriptService which is also the script that is supposed to re-enable the Server Script that’s inside a model.
I’ve tried other methods such as cloning the script from somewhere it wouldn’t activate, to the model itself, which also ended up in the same result.
I’m simply using the “.Enabled = true / .Disabled = false” code for enabling the script, I don’t know if there are any other methods of doing it.
I mean I’ve already tried using the Remote Event, which did not work as I’ve said in my article. I’m currently searching what I could do with BindableEvent but I still have some suspicion left for it since Remote Event did not work.
Yeah I don’t think BindableEvent is going to do it since they only allow communication through server scripts. For further information, I have a model that teleports near the player when the player presses the ‘i’ key. The scripts that teleports the model is a Local Script, ofcourse. I somehow need to also re-enable the script I’ve been talking about when that ‘teleport’ command happens.
You could solve this by copying your script into a spawned function; I am not sure why this might be failing you unless you are firing an object that doesn’t exist on the server ex:
-- LocalScript
local new_object = Instance.new("Part", workspace)
remote_event:FireServer(new_object) -- this will be nil to the sever
Your description does not sound like this is happening, though maybe you are firing the wrong remote event? StarterGUI is copied in to PlayerGUI so if the remote event is a child of StarterGUI it could be silently failing.
easy fix is to just use an attribute and set it on the script when you want to disable it and watch in the script when the attribute is there
script:SetAttribute('DisableScript', true) -- this would be the disable for the script
script:SetAttribute('DisableScript', nil) -- this would be the enable. just removes Attribute from the script together
then watch for the changes with getattributechangedsignal
script:GetAttributeChangedSignal('DisableScript'):Connect(function()
if script:GetAttribute('DisableScript') then -- this is when its disabled
else
-- this is when its enabled again
end
end)
The Remote Event is the child of Replicated Storage (not anymore though because I had to delete the Remote Event method to show what I’m trying to do in the video).
I’m going to make sure to try it out although I want to send this video first so it is better to understand what the purpose is if that’s alright. I don’t want any misunderstandings whatsoever.
Alright this is DeBox (Bad with names) and as seen in the video, I press the ‘i’ key to teleport it near me. When I type “Open” in chat, it does a tiny animation.
^ This is the script that activates when I say the keyword in the chat. This is also the script I want to enable in-game when It’s disabled at first.
wait(2)
local offset = Vector3.new(0, -2, -5)
local root = game.Players.LocalPlayer.Character.HumanoidRootPart
local ToolBox = game.Workspace["DebugTool-Box"]
local userInputService = game:GetService("UserInputService")
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.I then
print("Succefully called DeBox!")
ToolBox:SetPrimaryPartCFrame(root.CFrame * CFrame.new(offset) * CFrame.Angles(0, math.rad(180), 0))
ToolBox.Base.DropSound:Play()
script:Destroy()
end
end
end)
^ This is the script that teleports the box near me. I want this script to also somehow enable the other script. Also good thing to note is that this script is a Local Script and the other one is a Server Script inside the box.
The reason to why I want this script to enable the other script specificly, is because I don’t want to be able to make the box open itself UNLESS I tp it near me.
aha! the script is enabled and runs the problem is you are relying on a connection to have fired. PlayerAdded will be connected when re-enabled but it won’t have any players added unless they join after the script is enabled. Try doing the same script with existing players
for _, player in game.Players:GetPlayers() do
player.Chatted:Connect(function(msg)
-- ...
How about instead of checking if a player has chatted on the server, you do it on the client?
Then, you can use a RemoteEvent to move the box with a script on the server.
Plus, you won’t have to re-enable the server script over and over again, you just have to fire the RemoteEvent.
Could you possibly give a code / picture example? Sorry, I’m really bad at scripting in general and I don’t really know how to use Remote Events. I half looked up on Youtube for the last method.