Hi. I've created a very simple script, where if you touch the parent, it kicks your client:
script.Parent.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) player:Kick("You have been kicked.") end)
Now, with another script, I destroy the script with a LocalScript (StarterPlayer>StarterPlayerScripts):
local whitelist = {"namehere"} local plr = game:GetService("Players").LocalPlayer if table.find(whitelist, plr.Name) then game.Workspace.Brick:Destroy() return; end
This deletes it on the client, but if I die or reset my character while standing where the brick would be, it kicks me as if it was still there.
How do I kill the script?
Client changes do not replicate to the server, the client cant even see scripts, so you need to destroy the script on the server, but destroying/cloning/disabling/enabling scripts is a bad practice. If you want that the script doesnt kill you but others do then make the touched filter you out and kill the others if you just want to it stop killing at certain conditions then apply those conditions, but if you really want the client to turn on/off the killing mechanism then you can use a remote event to disconnect or connect the touched event
(script = server, localscript = client)
Destroy the script inside the brick instead of just the brick, then try to destroy the brick?
A better way to do this is to put it all into a single script. Also, it's better if you whitelist by a player's UserId ineatd of their username.
-- Variables: local whitelistID = {000101} local kickReason = 'You have been kicked from this session' script.Parent.Touched:Connect(function(touched) local plr = game.Players:GetPlayerFromCharacter(touched.Parent) if table.find(whitelistID, plr.UserId) then return else plr:Kick(kickReason) end end)