-- I just set random variables(These are variables right guys?) for the purpose of the script. local Scripter = "Over 9000" local Memes = 750 local Killer = true local KillBrick = script.Parent --KillBrick is the part that this code is inside lol if Killer == true then function PlayerTouched() game.Players:GetPlayers() Parent.Humanoid.Health = 0 end end
Why won't this work??? ugh xD
-- These are variables local Scripter = "Over 9000" -- String variable local Memes = 750 -- Number variable local Killer = true -- Boolean variable local KillBrick = script.Parent -- Parent of the script if Killer == true then -- Not necessary but you can use it for whatever purpose KillBrick.Touched:Connect(function(hit) -- Touched event fires when someone/something touches the brick if hit.Parent:FindFirstChild("Humanoid") then -- makes sure the "something" is a player/character local character = hit.Parent -- get character local humanoid = hit.Parent:FindFirstChild("Humanoid") -- get humanoid humanoid.Health = 0 -- kill character end end) end
GetPlayers()
Wasn't needed in this case, as with the touched event you can easily get the player/character.
-- I just set random variables(These are variables right guys?) for the purpose of the script. local Scripter = "Over 9000" local Memes = 750 local Killer = true local KillBrick = script.Parent --KillBrick is the part that this code is inside lol KillBrick.Touched:Connect(function(hit) h = hit.Parent:FindFirstChild("Humanoid") if h then h.Health = 0 end
You have to set a .Touched event with the brick you want the player to touch. Just because you wrote PlayerTouched as a function doesnt mean it will work like that. Function names dont matter. What does matter is how you call them.
If it doesnt work, then it's either because I put only one end or I forgot the right Health property. I didnt do this in studio i just made it up