As far as I know, this is a well done script, tell me if there is any flaws in this script,
-- Brick Variable
local Brick = script.Parent
-- Script
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
Parent.Humanoid.Health = 0
end
end
Brick.Touched:connect(PlayerTouched)
Thanks for your feedback.
This Script is Scripted by @Rebellion2895, as with every basic script, they are super basic so may seem like other peoples, feel free to take this script but if I ever post more complicated scripts please don’t use them, thanks!
It’s decent, consider proper camel usage- however that’s not really a necessity, it’s more preference, however it should eventually be standardized.
Name your variables what they are, if you’re expecting the part’s parent to be a character, then name it “character” over “parent”
Not really necessary but define your services- using GetService
I mean it’s pretty straight-forward, what would can you expect from a Kill Brick?
Only thing I’d suggest is creating a Player variable instead of detecting for the Part’s Parent, cause it may not find 1 if the Part’s Parent is equal to nil
-- Brick Variable
local Brick = script.Parent
-- Script
local function PlayerTouched(Part)
local Player = game.Players:GetPlayerFromCharacter(Part.Parent)
if Player then
Part.Parent.Humanoid.Health = 0
end
end
Brick.Touched:Connect(PlayerTouched)
Also connect is deprecated, do use Connect instead