So im trying to get the player, if he clicks a button(Text button) a part spawns, i got no problem with that, but when i try to make it so when the play touches the part they take damage, it doesnt work. Here is the following code
local btn = game.StarterGui.test2.test
function SpawnShadowPart()
local Shadow = Instance.new("Part")
Shadow.Parent = workspace
Shadow.Shape = "Cylinder"
Shadow.Name = "ShadowCurse"
Shadow.Position = Vector3.new(0,10,0)
Shadow.Orientation = Vector3.new(0,10,0)
Shadow.Color = Color3.fromRGB(170,0,170)
end
local shadow = game.workspace:FindFirstChild("ShadowCurse")
script.Parent.MouseButton1Click:Connect(function()
local Shadow = SpawnShadowPart()
Shadow.Touched:Connect(function(ShadowCurseEffect)
local humanoid = game.Players.LocalPlayer:FindFirstChild("Humanoid")
local maxHP = humanoid.MaxHealth
humanoid.Health = maxHP - 0.70
script:Destroy()
end)
end)
