I was making a script that makes multiple parts under a model become visible. The main script works although the scripts that run the mini-game itself are somehow affected by the code. I was wondering if there is a way to exclude the scripts from being affected. I have attempted to fix it myself although the issue is still there. If anyone can help me out with this that would be great. Here is some screenshots of the scripts and the code.
for _, Lower_Parts_Spleef in pairs(game.Workspace.Spleef_Platforms.Lower_Platform:GetChildren()) do
Lower_Parts_Spleef.Transparency = 0
Lower_Parts_Spleef.CanCollide = true
end
for _, Lower_Parts_Spleef in pairs(game.Workspace.Spleef_Platforms.Middle_Platform:GetChildren()) do
Lower_Parts_Spleef.Transparency = 0
Lower_Parts_Spleef.CanCollide = true
end
for _, Lower_Parts_Spleef in pairs(game.Workspace.Spleef_Platforms.Upper_Platform:GetChildren()) do
Lower_Parts_Spleef.Transparency = 0
Lower_Parts_Spleef.CanCollide = true
end
As you can see this code technically has nothing to do with a scripts properties although the scripts do not work when in game although, they do work without this code.
In the image above you can see the scripts that are being disabled / broken, here is their code:
script.Parent.Touched:Connect(function()
wait(.25)
script.Parent.Transparency = 1
script.Parent.CanCollide = false
end)
Each script under every part on all 3 Models has this scripts, I understand this is not effective although it is unfortunately all I could think of for this part of the game, all of the models are affected the same. Once again if anyone can help me out with this that would be great!
Sorry the code for the 1st section did not display correctly:
for _, Lower_Parts_Spleef in pairs(game.Workspace.Spleef_Platforms.Lower_Platform:GetChildren()) do
Lower_Parts_Spleef.Transparency = 0
Lower_Parts_Spleef.CanCollide = true
end
It is this block of code 3 Times for every section / model!
The main reason why this is happening is because the script does not contain the same properties as a part. Do something like this
for _, Lower_Parts_Spleef in pairs(game.Workspace.Spleef_Platforms.Lower_Platform:GetChildren()) do
if Lower_Parts_Spleef:IsA("Part") then
Lower_Parts_Spleef.Transparency = 0
Lower_Parts_Spleef.CanCollide = true
end
end
or you can use:
if Lower_Parts_Spleef.Name ~= "Spleef_Script" then
Lower_Parts_Spleef.Transparency = 0
Lower_Parts_Spleef.CanCollide = true
tldr; use IsA() to check
Why not just use 1 script?
for _, v in pairs(game.Workspace.Spleef_Platforms.Lower_Platform:GetChildren()) do
v.Touched:Connect(function(h)
v.Transparency = 0
v.CanCollide = true
end)
end
I recommend using tween to make it smoother, this will go through everything in lower platform then when touched it will have a transparency of 0, also I believe you want v.CanCollide = false
1 Like
Hello, unfortunately neither of the resolutions work, there are no Output errors so I could not tell you what the issue is with either.
Show us the picture of the model that is holding these all together please. I need to know what model these are held in.
also, why not use a single script.
I also tried using one script although that also did not fix the issue, heres the model and the explorer:
try and do a print debug. Replace the Transparency and the CanCollide of the v and replace it with,
print(type(v)
so that you know if there is anything wrong with it.
all of them that is not the script should be a part inside.
also I assume that Spleef_Functions is where you store the scripts.
I implemented this, I got the following output:
userdata(x...) -- The ... increases by 1 every part that is stepped on.
Like you said I only changed the lines that changed the properties of a part. Heres the code with what you asked me to implement.
for _, v in pairs(game.Workspace.Spleef_Platforms.Platform_Parts:GetChildren()) do
v.Touched:Connect(function(h)
print(type(v))
end)
end
After finding out that this worked and I received an output for each part I changed it back to this, although alike before nothing is affected. Heres the code:
for _, v in pairs(game.Workspace.Spleef_Platforms.Platform_Parts:GetChildren()) do
v.Touched:Connect(function(h)
v.Transparency = 1
v.CanCollide = false
end)
end