This script is suppose to only activate upon one part being clicked. I have filtering Enabled on and I am confused why it isn't working properly. This is set up inside a model. So that when a certain part is clicked then the rest of the model moves.
Classes
Model = 2Children[Main]&[Model]
Main is the part being clicked and the other model ha all the other parts inside of it. Which makes it so only one single part can be clicked. Inside a model.
Here is the script:
wait(1)
script.Parent.PrimaryPart = script.Parent.Main
local Main = script.Parent:GetPrimaryPartCFrame()
local part = script.Parent.Main
local clic = part.ClickDetector
local sound = script.Parent.Sound
local Sensor = part -- Path to the Click Sensor can change
function onClicked() -- Add whatever you want the button to do into the function
if script.Parent.Open.Value == 1 then
sound:Play()
fix = script.Parent.Main.CFrame
for i = 0,1.5,0.1 do
wait(0.05)
script.Parent:SetPrimaryPartCFrame(script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,-0.1,0)*CFrame.new(0.01,0,-0.25))
script.Parent.Open.Value = 0
clic.MaxActivationDistance = 0
end
script.Parent:SetPrimaryPartCFrame(fix*CFrame.fromEulerAnglesXYZ(0,-math.pi/2,0)*CFrame.new(-2.5,0,-2.5))
wait(0.25)
clic.MaxActivationDistance = 15
elseif script.Parent.Open.Value == 0 then
sound:Play()
fix = script.Parent.Main.CFrame
for i = 0,1.5,0.1 do
wait(0.05)
script.Parent:SetPrimaryPartCFrame(script.Parent.Main.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)*CFrame.new(-0.01,0,0.25))
clic.MaxActivationDistance = 0
end
script.Parent:SetPrimaryPartCFrame(fix*CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)*CFrame.new(-2.5,0,2.5))
wait(0.25)
clic.MaxActivationDistance = 15
script.Parent.Open.Value = 1
end
end
part.ClickEvent.OnServerEvent:connect(onClicked) -- Make sure ClickEvent and ClickDetector are inside the ClickSensor

3 comments
I don't think FilteringEnabled is affecting it. Try turning it off and testing it to make sure.
okay
The problem isnt filtering enabled... :/