Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a part have a Health attribute purely using code?

Asked by 4 years ago
Edited 4 years ago

So, im trying to make a boss prototype for my game, but I cant figure out how to make the boss be able to take damage(Its a part spawned using an Instance.new function)

Here is the following script

01function SpawnBoss()
02    local BossSpawn = Instance.new("Part", workspace)
03    BossSpawn.Size = Vector3.new(26.121, 44.027, 26.311)
04    BossSpawn.Position = Vector3.new(25,0,5)
05    BossSpawn.Color = Color3.fromRGB(0,0,0)
06    BossSpawn.Name = "Boss"
07    return SpawnBoss() 
08end
09 
10 
11local Boss = game.Workspace:FindFirstChild("Boss")
12script.Parent.MouseButton1Click:Connect(function()
13    local SpawnBossAct = SpawnBoss()
14    SpawnBossAct.Touched:Connect(function()
15        local plr = game.Players.LocalPlayer
View all 28 lines...
0
You're going to cause a stack overflow on line seven. Ziffixture 6913 — 4y

Answer this question