Hi everyone,
I am spawning large spheres to roll randomly down a slope to form obstacles the player must dodge. However, the objects only collide with the player pushing them back.
To make it harder I would like it to kill or reduce health on contact.
This is my normal hit code to kill the player in other areas such as a lava floor:
script.Parent.Touched:connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
if h.Health > 0 then
h.Health = 0
end
end
end)
but I need it to fit into the Sphere spawner script below:
local Debris = game:GetService("Debris")
local rball = Instance.new("Part")
rball.Anchored = false
rball.Shape = Enum.PartType.Ball
rball.TopSurface = Enum.SurfaceType.Smooth
rball.BottomSurface = Enum.SurfaceType.Smooth
rball.Size = Vector3.new(16, 16, 16)
while true do
newBall = rball:Clone()
newBall.BrickColor = BrickColor.new("Burlap")
newBall.CFrame = CFrame.new(250, 160, 140)
newBall.Material = Enum.Material.Cobblestone
newBall.Velocity = Vector3.new(math.random(-30, 20), 0, 0)
newBall.Parent = game.Workspace
Debris:AddItem(newBall, 12)
wait(2)
end
Tried all places but no joy, can anyone help?
Thanks again

2 comments
Make a ball with these properties and put them into ServerStorage. Then, put the script inside the ball in ServerStorage. Then, reference the ball and clone it
Brilliant this has worked, thank you very much :)