I have recently started coding, and following the courses on Studio+. The problem with this is that there is no course on making a obby. I have seen other threads about this but they require higher coding skills. Any scripts that could include the "if" statement? Cheers!
Any tips on how to make a kill script for begginers?
3 answers
yall are making this hard just use this
inside the killpart
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid:TakeDamage(100) -- Amount of damage
end
end)
Use Humanoid: TakeDamage
"script" inside the Killbrick
script.Parent.Touched:Connect(function(p)
p.Parent.Humanoid:TakeDamage(100)
end)
There Test it Out, i haven't tested it yet if there's problem just comment again
13 comments
This script does not work. The error is - "Humaniod" is not a valid member of the model.
It Works You should Put a ordinary script inside the part and not anywhere else because the script calls the Part because of that script.Parent so it should be the Child of the "Part"
Don't mind that error try stepping on that part it will surely kills you, its just the script runs even before you join the game
Thank you! It works.
told ya
When I copy and paste the script, it works. But when I type the script myself, it does not work. How do I fix this?
maybe there's wrong Capitalization/Spelling on it
Okay I will check.
This is my script. - script.Parent.Touched:Connect(function(p) p.Parent.Humanoid:TakeDamage(100) end)
whats the problem with it?
You should add "if" to see if the part that touches the brick really is a child of a player's character. Then you won't get the errors
You mean - if script.Parent.Touched:Connect(function(p) p.Parent.Humanoid:TakeDamage(100) end)
This is the error message I got when doing that script. - 18:35:49.841 - Workspace.Part.Script:5: Expected 'then' when parsing if statement, got
EDITED Put this in a script inside a part:
local p = script.Parent
local d = {}
p.Touched:Connect(function(hit)
local c = hit.Parent
local h = c:WaitForChild("Humanoid")
local p = game.Players:GetPlayerFromCharacter(c)
if p and h and not d[c] then
d[c] = true
h:TakeDamage(100) -- set to as much as you want, 100 will kill the player.
wait(2)
d[c] = nil
end
end)
If that helped please accept this answer.
All the best,
PrismaticFruits
6 comments
Have you ever used this script? It is not working.
Now try.
Thank you! This is working.
Can you please accept this answer?
How do I?
You just did it lol.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
I edited my answer. I used "." instead of ":"
.