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

I can't use the "Not". "Not" logic constructor is not working?

So Im trying to make a gun that can erase models, and my code for checking if its a model looks like this:

if parent:IsA("Model") or parent:IsA("Folder") and not parent:IsA("Workspace") and parent.Name ~= character.Name then

however, im not trying to be able to shoot anything thats not in a model and watching all the parts in the game dissapear. So i added a and not parent:IsA("Workspace") in the if to try and fix this issue. However, this doesn't work, and I've had issues with this sorta thing before, where i cant use "not" because its not working. Any help?

1 comment

0

What happens when you run this code?

2 answers

✓ Accepted answer

It is pretty redundant to put "and not" there, if it is a folder or a model it cannot be the workspace to begin with. I'd also recommend checking if the model has a humanoid if you're scared of deleting a player by accident by adding: and parent:FindFirstChild("Humanoid") == nil.

The problem is probably not on the if to begin with

I agree with @prooheckcp and I suggest putting the parts you're trying to delete in a specific folder because I doubt you want the players to be able to destroy the entire Workspace.

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