Part properties won't change with a script

this script won’t work
the answer to why is probably so obvious lol

btw i get no errors, and the scripts parent gets destroyed

local woodDisplayPart = game:GetService("Workspace"):WaitForChild("WoodDisplay1")

script.Parent.Click.MouseClick:Connect(function()
	woodDisplayPart.Transparency = 0
	woodDisplayPart.CanCollide = true
	
	script.Parent:Destroy()
end)

Add a ClickDetector into the part, and do this:

local woodDisplayPart = game:GetService("Workspace"):WaitForChild("WoodDisplay1")

script.Parent.ClickDetector.MouseClick:Connect(function()
	woodDisplayPart.Transparency = 0
	woodDisplayPart.CanCollide = true
	
	script.Parent:Destroy()
end)

There is a click detector, I just renamed it to “Click”

Add a wait before destroying (Characters)

Still didn’t work. [charsssss]

What type of script is this? Local or server

It’s a server script. (charss)

I don’t see any issues in your script probably try redifining the part

local woodDisplayPart  = game.Workspace:WaitForChild("WoodDisplay1")

Also have a look at your part’s children check if there’s an actual click detector before clicking. Sometimes backdoors can ruin your game if found.

What is it you’re trying to do in the script that’s not working? Just in case, to make something invisible you need to do .Transparency = 1, while 0 is completely visible.

I’m trying to make woodDisplayPart visible and CanCollide true when the click detector is clicked.

1 Like
script.Parent.Click.MouseClick:Connect(function()
    local woodDisplayPart = game:GetService("Workspace"):WaitForChild("WoodDisplay1")
	woodDisplayPart.Transparency = 0
	woodDisplayPart.CanCollide = true
	
	script.Parent:Destroy()
end)

Try this, and let me know how it goes. It could be that it needs to assign the variable when the MouseClick occurs, not just at the beginning of the script for whatever reason.

No that’s not the reason I just tried my own version and it totally worked, there’s no reason for yours to not work, probably check for weird behavior in your explorer as you might have backdoor going on.

2 Likes

Otherwise it could just be your own errors in setting the explorer environment

Try this:

local DisplayPart = workspace:WaitForChild("WoodDisplay1")

local Click = Instance.new("ClickDetector")
Click.Name = "Click"
Click.Parent = DisplayPart

Click.MouseClick:Connect(function()
	DisplayPart.Transparency = 0
	DisplayPart.CanCollide = true

	script.Parent:Destroy()
end)

Also make sure that the object is a BasePart (Wedges, Bricks, Spheres, Cylinders) and not a Model.

Why would you need to set the transparency and collision before you destroy it?

I’m not destroying the woodDisplayPart, i’m destroying the part you click to make it go visible.

ok… then:

local DisplayPart = workspace:WaitForChild("WoodDisplay1")

local Click = Instance.new("ClickDetector")
Click.Name = "Click"
Click.Parent = DisplayPart

Click.MouseClick:Connect(function()
	DisplayPart.Transparency = 0
	DisplayPart.CanCollide = true

	Click:Destroy()
end)