Hello, I have recently been in development of my new place. And I have a very simple kill brick that has this code;
function Kill(Plr) game.Players:GetPlayerFromCharacter(Plr.Parent).Alive.Value = false Plr.Parent:BreakJoints() end script.Parent.Touched:connect(Kill)
The Alive value and such are irrelevant, they do not seem to be creating the fuss. However, sometimes when jumping on a fairly short brick located on top of this kill brick, it will just kill the player anyway. However I've also had scenarios where you can be a few studs above the kill brick, where a death should be impossible to achieve via the kill brick, yet you can still die. This has given me a thought the the script may not be faulty, just the game is lagging. However, I'm clueless on the matter, does anyone have any words of wisdom for this issue?
I wasn't sure if the tag was correct, but it seemed partially relevant, so I used it.
You need to add a debounce, which can be done two ways, a debounce or checking the value in Alive. I am on my phone, so I will post a better version once I get to a computer.
function Kill(Plr) if game.Players:GetPlayerFromCharacter (Plr.Parent).Alive.Value==true then game.Players:GetPlayerFromCharacter(Plr.Parent).Alive.Value =false Plr.Parent:BreakJoints() end end script.Parent.Touched:connect(Kill)
Or...
function Kill(Plr) local Debounce = false if Debounce == false then Debounce = true game.Players:GetPlayerFromCharacter(Plr.Parent).Alive.Value =false Plr.Parent:BreakJoints() wait () Debounce = false end end script.Parent.Touched:connect(Kill)
Way 1 is recommended so no one can survive when both people touch it.
local A = false script.Parent.Touched:connect(function(Object) local Player = game:service'Players':GetPlayerFromCharacter(Object.Parent) if Player and not A then Player:LoadCharacter() A = true end end)