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

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

Asked by
alefa03 15
4 years ago
Edited 4 years ago

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)
0
Look at Roblox's tutorial on how to make a cannon and the cannon ball basically tells hoot make the explosion when touched stormaloo 0 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Is this supposed to explode

0
no, the player should explode when it touches the part, it works, but it causes heavy lag issuses which make the game crash alefa03 15 — 4y
Ad
Log in to vote
0
Answered by
alefa03 15
4 years ago
Edited 4 years ago

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

Answer this question