I'm trying to make a kill script for when players touch a kill brick in my obby. I tried using the Humanoid.Touched feature, however, this is glitchy. So, I need a better alternative. Could someone please help me? Script:
local CS = game:GetService("CollectionService")
local Players = game:GetService("Players")
function OnHumanoidTouched(otherpart, limb)
local player = Players:GetPlayerFromCharacter(limb.Parent)
if CS:HasTag(otherpart, "Checkpoint") then
--some checkpoint stuff
elseif CS:HasTag(otherpart, "KillBrick") then
player.Character:WaitForChild("Humanoid"):TakeDamage(100)
end
end
function OnCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid");
humanoid.Touched:Connect(OnHumanoidTouched)
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(OnCharacterAdded)
end)

2 comments
Not using .Touched because it fires multiple times
And its glitchy