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

Help with Model Transparency Command Script?

Hi..(Thanks for any help in advance) I am making a command script for my group and i already have most of the commands done but this one isnt working. when i say open this model with 4 parts becomes Visible. I already tried it with a part and it worked but i transferred the script to the model and now its not working. Output shows nothing but I think whats messing up something is when I call the model. I dont think its the chatted part or the admin part because it worked when it was a part and like ive said ive already made other commands. Here it is...

local Admins = {"iSvenDerp"}
P = script.Parent:GetChildren("Part","Part","Part","Part") 


function checkAuthority(name)
	for a,v in pairs(Admins) do
		if v == name then
			return true 
		end
	end
	return false
end




game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == "open" or msg == "Open" and checkAuthority(player.Name) then
            P.CanCollide = true
            P.Transparency = 0
        
        end
    end)
end)



game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == "close" or msg == "Close" and checkAuthority(player.Name) then
            P.CanCollide = false
            P.Transparency = 1 
        
        end
    end)
end)

2 comments

0

Why on line 2 do you define the 4 "Part"? :GetChildren() doesnt require anything but a location to get the children from.

0

I get what your saying but i also had a script in there so i could till do it and it wouldnt hurt anything right?

2 answers

✓ Accepted answer

Your blocks aren't anchored, which explains why they fall down, and are eventually destroyed. You wouldn't see the process because you're setting the transparency property of the parts to 1.

There's two things wrong. First, your table P. With :GetChildren() it doesn't need any arguments meaning you should replace script.Parent:GetChildren("Part","Part","Part","Part") with script.Parent:GetChildren()

Second, it looks like you're trying to make the table transparent and Non-Collidable, not the actual parts. One way of fixing this would be to replace

P.CanCollide = true
P.Transparency = 0

with

for i, v in pairs (P) do--Loops through the children of `script.Parent`
	if v:IsA("BasePart") then--Makes sure that the object is a part
		v.CanCollide=true
		v.Transparency=0
	end
end

And do the same with

P.CanCollide = false
P.Transparency = 1

11 comments

0

Hi..Thanks for helping and i think your right but it still doesnt work i got an error 09:45:39.187 - Workspace.Chamber.Script:28: unexpected symbol near ')'

0

he forgot an end.

0

Derp sorry xD

0

? so could u show me where? :3 i am just a poor little boy

0

On line 2 you checked if v is a basepart and never ended it.

0

I know what I did ... also iSvenDerp replace just add an end after v.Transparency=0

0

I can't test it right I should he able to in a few hours

0

Still doesnt work:( 16:07:14.491 - Workspace.Chamber.Script:28: unexpected symbol near ')'

0

pairs( to next, ? since 'i' is not being used..

0

Sorry about that ... again ... If you copy and paste again it should work

0

Thanks for the help

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