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

script rejects a line of code added to a working script?

hello, I was working on this code:

local debounce = false

script.Parent.Touched:Connect(function(hit)
	
	if not debounce and hit.Name == "Core" then
		
	
	debounce = true
		
		local weld = Instance.new("WeldConstraint")
		weld.Parent = script.Parent
		weld.Part0 = script.Parent
		weld.Part1 = hit
		wait()
		script.Parent.Stick1b.Disabled = true
		script.Parent.Name = "OrbPart2"
		wait(0.1)
		script.Disabled = true
		wait(2)
		debounce = false
	end
end)

the code worked nicely and I just needed to add one more thing to it:

local debounce = false

script.Parent.Touched:Connect(function(hit)
	
	if not debounce and hit.Name == "Core" then
		
	
	debounce = true
		
		local weld = Instance.new("WeldConstraint")
		weld.Parent = script.Parent
		weld.Part0 = script.Parent
		weld.Part1 = hit
		wait()
		script.Parent.Stick1b.Disabled = true
		script.Parent.Color.Disabled = false
		script.Parent.Name = "OrbPart2"
		wait(0.1)
		script.Disabled = true
		wait(2)
		debounce = false
	end
end)

I added some code to enable a script inside the same part but it doesnt seem to like it very much and stops right were I added the new line. I dont understand why script.Color.Disabled comes as an error when the line script.Parent.Stick1b.Disabled works just fine. if its something I missed let me know, thanks.

2 answers

This is occurring because Color is already a property of parts. When you use script.Parent.Color, instead of referring to the script inside the part called 'Color', it refers to the Color property of the part as it has the same name.

To fix this, all you should need to do is change the name of the script to something different like ColorScript, and then use the new name instead:

script.Parent.ColorScript.Disabled = false

Hope this helps!

1 comment

0

it works thank you, I had no idea script names would interfere with parts.

I like mattscy's answer however you can just use the function :FindFirstChild() as this will NOT reference the property Color if you use it. You can simply do;

script.Parent:FindFirstChild("Color").Disabled = false

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