Master is the Character that has the dialogue over his head so what im trying to do is make it so if you choose the ResponseDialogue then all the parts / children of "Master" the character are able to walk through but it doesn't work..
Please help me what is wrong in the script?
Master = script.Parent.Parent.Parent.Parent:GetChildren() Choice = script.Parent function truth() if Choice.ResponseDialog == true then Master.CanCollide = false wait(1) Master.CanCollide = true end end
So from what I understand (and correct me if I'm wrong), but you have a dialog over the head of a Non-Player Character, and when you click this dialog and select a specific choice then it makes all the parts in "Master" noncancollide.
First off, the "ResponseDialog" is what it will say when you click the option. If you wanted it to say "Hello" when you clicked the option "Hi", then you would put "Hello" in the "ResponseDialog" option in Propeties
I'll be sure to explain what i'm doing so you can learn how this works
Please note, I am not the best scripter in the world. If I do something that could be done simpler, it's because of my lack of experience. If a better coder see's this, comment on my answer, and I'll edit the script to make it simpler (This is so I can also learn from this experience)
Because I do not know exactly how the parts are set up in your studio, be prepared to edit some things
I did test this script in studio myself, and it should work.
Master = script.Parent.Parent.Parent.Parent Choice = script.Parent Dialog= script.Parent.Parent -- This may need to be changed, just put it to whatever the dialog is Dialog.DialogChoiceSelected:connect(function(player,chosen) --This is a function that will activate the code below, if you click the dialog above the NPC's head and select a choice it gives you if chosen.Name==(Choice.Name) then -- Here we are seeing if the dialog choice that they clicked is the same as the one that you want them click to make the parts noncancollide. for k,p in pairs(Master:GetChildren()) do -- Here we are getting all the children of "Master". This "for loop" will go through all the children of "Master" and do the code below. p.CanCollide=false end wait(1) -- This is how long the parts are walk-through. I'd suggest making it longer so people have a chance to go through. for k,p in pairs(Master:GetChildren()) do -- This is to get them again to close p.CanCollide=true end else end end)