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

Won't Make All Players CanCollide False?

I created a local script inside of Starter Pack to make all players CanCollide false. When I test with 2 people with the test option in studio, it works the first second then stops. I get no error. Here is the code:

local player = game.Players.LocalPlayer
local character = player.Character
wait(.1)
game:GetService('RunService').Stepped:connect(function()
local parts = character:GetChildren()
if parts.ClassName == "Part" and parts.ClassName == "Hat" then
	parts.CanCollide = false
	
end
end)

2 comments

1

Is FE turned on?

0

No it is not, but doing so would break the whole game

1 answer

✓ Accepted answer

You're using tabled wrong.

The GetChildren() method returns a table of everything inside of whatever you called the function for.

ScriptGuider explains tables very well. Here's a link to his answer.

Your question,

For your question, we don't even need to use tables really. Besides looping through one. We're going to use a Pairs Loop. A pairs loop will let us loop through everything inside of a table and give us the value in the table each loop.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
wait(.1)
game:GetService('RunService').Stepped:connect(function()
	local parts = character:GetChildren()
	for i,v in pairs(parts) do
		if v:IsA("Part") then
			v.CanCollide = false
		end
	end
end)

I also waited for the character to load, and checked if what was inside the character was a part.

I'm not sure this is going to make the character a ghost, but this is a fix to your problem.

Good Luck!

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