So I wanted to do a script in which I would spawn a sphere where the player is, and it would take damage and hold them in that Sphere for eight seconds. But It's not working.
local Player = script.Parent.Parent local mouse = Player:GetMouse() function YamiCage() if mouse.Hit ~= nil then S = Instance.new("Part") S.BrickColor = BrickColor.new("Really black") S.Transparency = 0.5 SM = Instance.new("SpecialMesh") S = SM.Parent SM.MeshType = "Sphere" SM.Scale = Vector3.new(1.1, 1.5, 1.5) S.CFrame = CFrame.new(mouse.Hit.p) local human = S:FindFirstChild("Humanoid") if(human ~= nil) then Humanoid.Health = Health - 2 end game:GetService("Debris"):AddItem(S, 8) end end mouse.Button1Down:connect(YamiCage)
I need some answers :c
You need gave the part a parent so it defaults to nil meaning it doesn't render. You also tried redefined your S variable to the mesh's parent to nil because you never assigned a parent to the mesh. Meshes need to be assigned to a child of the part. I'll add comments and put the part in Workspace and put the mesh in the part.
local Player = script.Parent.Parent local mouse = Player:GetMouse() function YamiCage() if mouse.Hit ~= nil then S = Instance.new("Part", Workspace) --I put the part in the Workspace S.BrickColor = BrickColor.new("Really black") S.Transparency = 0.5 SM = Instance.new("SpecialMesh") SM.Parent = S --Changed SM's Parent to the part created earlier SM.MeshType = "Sphere" SM.Scale = Vector3.new(1.1, 1.5, 1.5) S.CFrame = CFrame.new(mouse.Hit.p) local human = S:FindFirstChild("Humanoid") if(human ~= nil) then Humanoid.Health = Health - 2 end game:GetService("Debris"):AddItem(S, 8) end end mouse.Button1Down:connect(YamiCage)