Weird Bug With Script Not Finding Part

I’m trying to change the transparency of a part after its clicked yet somehow the script is not managing to find it but when I make a print 1 line before the transparency changing it does find the part.

Is this a bug from roblox?


image

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GetTool = ReplicatedStorage["Yellow CD"]
local GetParent = script.Parent



GetParent.ClickDetector.MouseClick:Connect(function()
	print(GetParent.CanPick.Value)
	if GetParent.CanPick.Value == true then
		print("passed condition")
		print(GetParent.Parent.YellowCD)
		GetParent.Parent.YellowCD = 1
		print("changed transparency")
	
	end
end)
5 Likes

If your trying to change transparency then do:

GetParent.Parent.YellowCD.Transparency = 1

Can you give us the directory of the script? You only gave us for the model, we need one for the script as well. I am confused as to why it works sometimes according to you.

1 Like

Should be

GetParent.Parent.YellowCD.Transparency = 1
1 Like

Still does not change

It never works I tried lots of ways
image

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GetTool = ReplicatedStorage["Yellow CD"]
local GetParent = script.Parent

GetParent.ClickDetector.MouseClick:Connect(function()
	if GetParent.CanPick.Value == true then
		GetParent.Transparency = 1
	end
end)

Copy pasted the script, still same issue

image

Are you sure can pick is enabled? Because I tested the same setup and it works for me.

1 Like

yes the value gets printed and prints that it passes the condition


image

Can you make a different script that does the same thing without any if statement or any other variable?

Didn’t work either
image
image

Is there any other script messing with the part?

Perhaps it is the placement of your script, where is your script place, and what type of script is it? LocalScript or just Script (meaning serverScript). Reply to this so we can further discuss

They have already showed us the script placement and type here. Please read the topic thoroughly before asking questions.

image
this local script that only sets the CanPick to true and make the part visible which only runs once.

Now that I think of it, could it be its because of this local script that set the CanPick to true?

Indeed, your solution should work

JF17Tjacktystlc

Lokispades

28m

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GetTool = ReplicatedStorage["Yellow CD"]
local GetParent = script.Parent

GetParent.ClickDetector.MouseClick:Connect(function()
	if GetParent.CanPick.Value == true then
		GetParent.Transparency = 1
	end
end)

This is all correct

One thing is to check it on another baseplate. Get your model and put it in another baseplate and test the script.

The code logic is correct but the OP’s problem is more complicated than I thought.

Also, dear god, PLEASE, fix ur variable naming, it is hard to mentally keep track of it