tool.Activated won't work for some reason

I’m attempting to make this script activate another script when this tool is enabled but for some reason it won’t work. I’ve looked at my previous working scripts and all over the dev forums just for some reason it won’t work.

local script = script.Parent.Handle.GloveScript
local tool = script.Parent

tool.Activated:Connect(function()
	script.Enabled = true
	task.wait(0.5)
	script.Enabled = false
end)

Any sort of help would be greatly appreciated.

You uh, you got it a little mixed up there buddy


Also in general that’s not how you’re supposed to use the Enabled property. Use BindableEvents

The “script” global is shadowed by your local variable in the first line which points to the script you want to be toggling. The second line uses that reference instead of the current script so the “tool” variable is now set to the handle. Instead of “script” try “gloveScript” as the name. The tool variable should still use the “script” global.

In the studio script editor, you can see globals like script get colored differently. Unless you know what you’re doing shadowing a variable, you can lose track of where it’s pointing.

I mean like for some reason the script is saying that Activated isn’t a property or function or whatever of the tool

I did something and it somehow worked thanks though

Activated isn’t an event on the handle part which the tool variable was pointing to instead.

If you have the correct fix you don’t have to mark another reply as the solution. You can mark yourself as the solver. But also, what fixed it?

I honestly couldn’t tell you roblox was like adding random code when I wasn’t looking and it just randomly started working.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.