Problem with simple script

I’m making a script that when a boolvalue is false, the part didn’t appear, and when the value is true, the part appear.

Thats the script

while true do
	if script.Parent.Active.Value == true then
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
	else
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
	end
	wait()
end

Maybe try splitting the if statements and use 2 loops

1 Like

You’ve got your transparency the other way round. Should be :

while true do
	if script.Parent.Active.Value == true then
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
	else
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
	end
	wait()
end
1 Like

Nothing updates the value of Active, although you probably have anotehr script for that, also, it’s better to use .Changed for this case

local part = script.Parent

part.Active.Changed:Connect(function(newval)
	part.Transparency = newval and 0 or 1
	part.CanCollide = newval and true or false
end)

If something doesn’t work how you want it to, just switch the values around

3 Likes

It’s true

But didn’t worked, when i change the value, the part doesn’t show/hide

How are you changing the value? Command bar? And what type of script is this and where is it located?

1 Like

The value/script is inside the part, and I’m changing the value with the explorer

What type of script is it? And are you changing the value from the Explorer from the perspective of the Client or the Server?

1 Like

It’s a normal script, and I tried change the value in the client/server

If you change it from the Client, the server cannot detect it so it wont do anything, you can try this as a test

local part = script.Parent

part.Active.Changed:Connect(function(newval)
	part.Transparency = newval and 0 or 1
	part.CanCollide = newval and true or false
end)

wait(10)

part.Active.Value = true

If it doesn’t work, then switch 0 and 1 around and also true and false

2 Likes

Are you sure that your value is a BoolValue?

1 Like

Ok, I’ll try later, (10%, I need to charge now)

1 Like

Yea, the value is a bool value.

local part = script.Parent
local active = script.Parent.Active

if active.Value == true then
	part.Transparency = 0
	part.CanCollide = true else
	part.Transparency = 1
	part.CanCollide = false
	
	
end

Here, it worked for me when I tested it

Screenshot 2021-04-08 at 23.30.43

Just make sure your hierarchy looks like this.

How on earth do you have the old explorer from 2017?

Just can’t be asked to change the theme, it’s not the laptop I used before, not like the them matters unless you have sensitive eyes

Edit: and I use dark theme for the dev forum anyways

But how can you enable that (Triangles and bold text and old logos)

I met it like that, I didn’t enable anything

Let’s do this in a dm then, this is getting off topic

Works just fine for me. Make sure your part is anchored!
https://i.gyazo.com/01ea76c21c0ae3919ec5b4944645e842.mp4