How do I make it so that .Touched events don't work on a certain part

If the scripts are put from other people, then what’s stopping them from just making some code to destroy the part? The only way I know you could somewhat prevent that is to just check if something got removed from workspace and if it’s a part you didn’t want gone, just Clone it from replicatedstorage and put it back.

Basically, place the parts wherever and copy them to ReplicatedStorage with all the properties you want already set then you can just run some code

local cantremove =  game.ReplicatedStorage.UnremoveableParts:GetChildren() --We get all the parts you can't remove from a folder

workspace.ChildRemoved:Connect(function(child)
    for i,v in pairs(cantremove) do
        if child.Name == v.Name  then --We'll use their name in this case
            local clone = v:Clone()
            clone.Parent = workspace
            break
        end
    end
end)

This is one way how you could do that, but it would be slow and probably unoptimal given the right conditions. If a part you didn’t want gone was removed, then it will place it back in workspace, you don’t really need to set the Position or anchors since you already did that when the part was copied to a folder in ReplicatedStorage. This will require the unremoveables to have a unique name if possible to not cause conflict

I thought of doing this, but in my case it’s actually the character I don’t want destroyed (it would result in death if the torso or head got destroyed).

In terms of preventing the Character from not being destroyed, that’s a bit more difficult to do since it’s not as simple as the previous example was, nor do I know of a proper way you could instantly respawn the player’s character and put it back where it was. This is a problem with Script Builders, it’s kinda anarchish, there’s no proper way to prevent players from doing a specific thing.

What you could try is in every Character there’s a script that checks if they died and they don’t have a Head or a Torso, which shows that they died via :Destroy(), and if they were killed by that, store the CFrame of the HumanoidRootPart if they didn’t destroy it too, load the character again and move them to their original position

I know how to do this simply, but if I did I would have to run my script again I think.

If players are creating code on their client, they won’t be able to affect other players characters.

Sure if I make a script that deleted all other characters but my own, they will be deleted on My client, but not on their.
The server won’t replicate that unless you provide a means to do so (sending coding to the server to run).

If that’s the case, you should look into parsing the clients code for inappropriate commands or actions.

With a script builder, they can insert regular scripts.

I don’t think you have to run the script again, which one are you referring to?

Well, I mean with my current require script that I have made, it requires the script to be reran when the character respawns.

If that’s the case you likely have Filtering Enabled disabled, in which case you’re just asking for trouble.

I’d strongly recommend setting up a system to incorporate FE, or only run code on the client (doesn’t replicate).

If you just allow the player to run their own scripts client side, there won’t be any issues of players creating malicious code to affect others.

If the player decides to delete their own character, or any other required instance, you could make a client script to detect that and reset the player so they don’t need to leave.

I believe you can do that using the CharacterAdded event to check that once the character respawns, jsut rerun the code, unless it’s a problem to do so

Script builders are meant for allowing this, they allow anyone to execute scripts in the game, that’s what the game is about.

I could, but that would mean in order to run a different script I’d have to rejoin and I don’t want that, it might be possible for me to connect the function to an if statement that can check if I actually want it disabled though…

You could try that and see how it goes, I have no experience in Script Builders so I’m not what the best approaches could be

Yea, I’ll try it out later, got school right now though so I’ll reply on how it went later.

If you want, you can also DM me on discord: Crazycarkids#0181

Alright, good luck and h ope it goes well!

I got it working, while making it a lot more OP in the process. If you want the require script for it DM me on discord or just go to Chronos Release

1 Like

maybe

local white_list = {a part, a part, a dummy part}

part.Touched:Connect(function(stuff)

--check every white listed parts
for _, stuff__ in next, white_list do
if stuff == stuff__ then return end -- white listed part
end
--code to run
stuff:Destroy()
end)

Read through the whole thing before answering, also I marked a solution already.

em ok, i dont see if it has already have a solution.
anyways im just answering questions