I'm making a basketball court game. So I have a block that on touch freezes the character in order to keep them on a team spot, but if they want to exit they can, but I need them to be unfrozen, of course. This is my code for the block that will unfreeze them, but it won't unfreeze:
function touched(part) if not game.ReplicatedStorage.RemoteEvent then end if part.Parent:FindFirstChild('Humanoid') then local n = part.Parent local all = n:GetChildren() for i=1,#all do if all[i]:IsA("Part") then all[i].Anchored = false end end end end script.Parent.Touched:Connect(touched)
If anyone could help me figure this out it would be much appreciated! I'm very new to scripting.
Problem: Your problem is using :IsA"Part". Most of the parts in the character aren't parts. They are meshparts. But some can still be parts..
Solution: To resolve this, use the highest class which includes them all: basepart.
Use IsA"BasePart", this I think will fix your problem unless there's more than 1 problem. Which in that case, something would have to be terribly wrong like the wrong character something but that's unlikely.
Suggeations: I suggest you look at things more closely, see what your working with. You tried to look in the character for things with the class name "Part", well, if it doesn't work, you should have looked din the character manually to see if what is in the character are what you think is there, which in this case it's not, you would have seen that they are meshparts if you checked. Please do this in the future.
Hope this helps :3