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

[SOLVED] Player killer script: What can i do to avoid lag?

I've made an explosion using a sphere and TweenService. I've also made a script which has to kill the player using a character explosion, but the game starts to lag during the explosion until it crashes. I've added some delays and a debounce value, but the script continues to cause heavy lag.

Here's the "PlayerKiller" script:

local done = false

function ontouch(hit)
	if not done then
		done = true
	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
		local exp = Instance.new('Explosion')
		exp.Position = hit.Position
		exp.Parent = workspace
	end
	else
		wait(2)
		done = false
	end
	wait(1)
end

wait(1)
script.Parent.Touched:Connect(ontouch)

1 comment

0

Look at Roblox's tutorial on how to make a cannon and the cannon ball basically tells hoot make the explosion when touched

2 answers

Is this supposed to explode

1 comment

0

no, the player should explode when it touches the part, it works, but it causes heavy lag issuses which make the game crash

Ok, I solved the problem using a local script for each player and not a single script in the exploding part. Thanks anyway.

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