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

How can I fix my code for unfreezing the player?

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.

6 comments

1

try GetDescendants() instead of GetChildren(), doubt it will make a difference but you might have a custom character. Also check for errors, also I'm pretty sure if you have mesh parts and unions in the user, those will stay anchored.

0

Didn't work sadly. I appreciate the suggestion so thank you, but the character is not a custom character either. I should have stated that the freeze is the same script but all that is changed for the unfreeze part and freeze part is whether Anchored = true or false.

0

@CameUpFromNothing, what doesn't work in your script? Explain more in your question, with what your goal is with examples etc.

0

Make sure you send us your whole script.

0

That's the entire script, and what I described was the exact problem. I don't really know what else to say.

0

idk, the code looks fine to me

1 answer

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

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