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

My script where if you are using the tool you go through walls, isn't working, I tried and failed?

So, I attempted to make a script in a tool that lets the player using the tool go through walls, not floors. I have no clue and don't know what to do. Here is my code:

while true do
	script.Parent.Torso.CanCollide = false
end

2 answers

✓ Accepted answer
  1. Since loops have no delay time without the wait function, that script will cause a script timeout / it will freeze your game for a period of time. So consider using another method.

  2. I don't know why but Torso.CanCollide=true regardless if you change the property or not. So why not make the other part's CanCollide false?

1 comment

0

I have a question, I have no clue how to change the player who is using the tools stats, how would I? Would I need to keep doing script.Parent?

I would add the walls you want to be collision-less in their own folder or have a value inside them for identification.

--local script
local walls = workspace["Walls Folder Here"]
script.Parent.Equipped:Connect(function()
	for i, v in pairs(walls) do --Loops through each item in the walls folder
		v.CanCollide = false --Sets their CanCollide property to false
	end
end)
script.Parent.Unequipped:Connect(function()
	for i, v in pairs(walls) do
		v.CanCollide = true
	end
end)

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