I've been trying to learn more scripting and practice more often. My friend created a game and asked me to help, and he let me script (Its an obby game btw) I have been trying to make a brick that will at a random moment turn Neon and kill the player. This is the script I created and am confused why it isn't working, I really only need a little guidance on what I should fix and how to fix it.
Also, if I would need separate scripts for it tell me, but it would be nice if there were a way to avoid that
The script:
local noTrust = script.Parent
while true do
wait(math.random(3,5))
noTrust.Material = "Neon"
noTrust.Touched:Connect(function(hit)
local human = hit.Parent:FindFirstChild("Huamnoid")
if human ~= nil then
human.Health = human.Health - 100
else
wait(math.random(3,5))
noTrust.Material = "Plastic"
end
end)
end

2 comments
I am sorry DesertusX that I didn't mark your answer as the solution. It was my fault for not making it clear enough for you to see what I had in mind. You helped me understand my problems very well
No problem!