Enabling scripts from touch won't work

Hello,

I did a script that is supposed to disable the other 2 local scripts and set the parent of a tool when a part is touched. The script:

local portalGun = workspace.World.NotPlaceable.PortalGun
local realTool = game.ServerStorage:WaitForChild("PortalGun")


local function onTouch(part)
	local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
	if humanoid == nil then return end
	script.Parent.ActivatePortals.Disabled = false
	realTool.Parent = script.Parent
	portalGun:Destroy()
	script.Parent.FirstPersonArms.Disabled = false
end

portalGun.Touched:Connect(onTouch)

The only part that works is destroying that gun.
This is the explorer:
Help
No errors or something in output.

Any help, please?

You’re setting the .Disabled property to false, you have to set it to true to disable them.

I want to enable them. What was wrong there?

Oh, nevermind then. Your post sort of implies you’re trying to disable them, not enable

Try using Bindable Events instead of disabling/enabling scripts.

Can you give me an example, please? I am newbie to these

If you know nothing about Bindable Events I advise you to watch this - YouTube
and read this BindableEvent | Documentation - Roblox Creator Hub

:slight_smile:

Something like this?

local ScriptService = game:GetService("ServerScriptService")
local event = ScriptService:WaitForChild("Event")
local portalGun = workspace.World.NotPlaceable.PortalGun
local realTool = game.ServerStorage:WaitForChild("PortalGun")


local function gotGun()
	script.Parent.ActivatePortals.Disabled = false
	realTool.Parent = script.Parent
	portalGun:Destroy()
	script.Parent.FirstPersonArms.Disabled = false
end
event.Event:Connect(gotGun)

local function onTouch(part)
	local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
	if humanoid == nil then return end
	event:Fire()
end

Ugh, it does the same thing, just destroying the fake portal gun, and it doesn’t set the parent of tool nor enables the local scripts

You have script A who enables the event. In script A you put:

Eventname:Fire()

You have script B who runs the event. In script B you put:

Eventname.Event:Connect(function()
–anything you want to happen, put it here.
end)

Dont’ forget to add a Bindable Event in the explorer, or create on with Instance.new()
NOTE: The name of the Bindable Event must me “Eventname” which you also use in the Eventname:Fire / Eventname.Event:Connect

I added the Bindable Event to ServerScriptService, but thanks, I will try, and yes, I know how to work with names

Thank you, I made it happen! Though I just deleted a part from a script and it worked!