Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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?

0
What happens when you run this code? kjljixx 42 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago

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

Ad
Log in to vote
0
Answered by 3 years ago

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.

Answer this question