You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make a part that has a kill script inside of it using a script (using instance.new)
What is the issue? Include screenshots / videos if possible!
I have decided to take matters into my own hands and watch AlvinBlox in order to learn how to script, and so far he’s mentioned instancing but it was just basic instancing, like the script at the bottom
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t tried anything so far
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
local damage = 10 -- Amount of damage per "waittime", 100 is instant death
local waittime = .1 -- The time to wait to damage
local part = Instance.new("Part")
part.Name = "MyAwesomePart"
part.BrickColor = BrickColor.new("Really red")
part.Anchored = true
part.Position = Vector3.new(0, 15, 0)
part.Transparency = 0.5
part.Reflectance = 0.6
part.CanCollide = false
part.Parent = workspace
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local hum = hit.Parent.Humanoid
wait(waittime)
hum.Health = hum.Health - damage
end
end)
I know this is not instancing a script, but it still works as a kill part.
First of all you can’t declare a local with a capital “L” in local. Secondly to achieve this all you need to do is have a template kill script which is cloned inside the part being made, for instance:
local killscript = workspace.KillScript --change this if necessary to reference your own killscript
local part = Instance.new("Part")
part.Parent = workspace
part.Name = "MyAwesomePart"
part.BrickColor = BrickColor.new("Really red")
part.Anchored = true
part.Position = Vector3.new(0, 15, 0)
part.Transparency = 0.5
part.Reflectance = 0.6
part.CanCollide = false
local ksclone = killscript:Clone()
ksclone.Parent = part
also another thing: I’m guessing I could put all that in a fucntion and add a “wait” command between calling the function if I wanted a new boulder to spawn every so often?