Crash when touched a part

hello!
i want to make a script where if player touches a part, something happens that crashes his game. maybe create A LOT of lag so he crashes. how do i do that? i want the script to be local so only the player who touches the part crashes.

2 Likes

well you can do it by making a inf loop or just inserting tons of stuff on client. i recommend the loop one since its much easier and can be coded really easily.

Here’s the code:

local part = workspace.Part -- just a test part in workspace, add your part here
part.Touched:connect(function(touching)
    if touching:IsA('BasePart') and touching.Parent:FindFirstChild'Humanoid' then -- its a player or someone with humanoid
          local model = touch.Parent
          if game.Players:GetPlayerFromCharacter(model) and game.Players:GetPlayerFromCharacter(model) == game.Players.LocalPlayer then
                 while true do end -- inf loop, make sure its on client.
          end
    end
end)



ok that script seems to work
BUT
it activates even when dummies touch the part, but i want it to only activate when the player touches the part
i also want the player who touched the part crash and not the whole server. how do i do it?

Turn it to local!
Anything that happens local happens to the specific user.
If its a module you maybe doing it globally and all users will suffer from lags.
hope that solves the problem.

1 Like

If you put this script into StarterCharacterScripts, you can also check to see if the part touched is part of the character.

Sorry for the post I made earlier, I didn’t read your text very well. To crash the local you’d have to oversend requests to the player. So I was thinking about:

Make a RemoteEvent somewhere on the client and whenever the part is touched you fire the remote to the player and this should be the code on the localscript:

local crash
local remote = (define your remote here)

remote.OnClientEvent:Connect(function()
	crash = true
	coroutine.wrap(function()
		while crash == true do end
	end)()
end)

I just tested it and it did crash my game!

how do i fire the remote event exactly?

updated it for you. will now check for localplayer.

1 Like

Well you just have to fire it from the server so in a serverscipt u can do

remote:FireClient(plr)

but you can also use the touched event in a localscript instead of a server script so you can write this in a localscript:

part.Touched:Connect(function(x)
	local hum = x.Parent:FindFirstChild("Humanoid") or x.Parent.Parent:FindFirstChild("Humanoid")
	if hum then
		while true do end
	end
end)