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

Why won't this script work, even though everything is right?

I checked all the syntax and there aren't any errors that I can see. Can you guys find something?

if game.Players.LocalPlayer.Backpack.Staffcard == true then
	for i,child in pairs(game.Workspace.Workdoors:GetChildren()) do
		if child:IsA("Part") then
			child.CanCollide = false
		else
			child.CanCollide = true
		end
	end
end

3 comments

0

What about this script isn't working?

0

Collisions aren't turning off

0

Please help

1 answer

If Staffcard is a value inside the Backpack, you have to check if Staffcard.Value == true instead of just Staffcard == true (the instance itself will always be treated as being true). Also, if you wanted this to happen whenever the Staffcard value changed, you would have to put it in a Changed function. Also I'm not sure why you're tying to change the CanCollide of something if it isn't a part.

game.Players.LocalPlayer.Backpack:WaitForChild("Staffcard").Changed:Connect(function(newVal)
	for i,child in pairs(game.Workspace.Workdoors:GetChildren()) do
		if child:IsA("BasePart") then
			if newVal == true then
				child.CanCollide = false
			else
				child.CanCollide = true
			end
		end
	end
end)		

Otherwise, if it is a tool, you may want to look into using FindFirstChild or ChildAdded.

1 comment

0

I'm trying to make all the parts in a model have no collisions.This doesn't work for some reason

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