So could someone help me convert this p.CFrame = p.CFrame * CFrame.new(Vector3.new(0, -4, 0)) to velocity that moves at the same speed as -4? I need to convert it to velocity because I heard I can't detect if the part touches something when it's getting cframed.
Well, if you did this:
p.CFrame = p.CFrame * CFrame.new(Vector3.new(0, -4, 0))
it would immediately move it down 4 studs, but if you used velocity, it would gradually move down. I'm assuming you would prefer the latter; in that case, you would use a for loop:
for i = 1, 10 do -- Change the 10 to how much you want the part to move down. 10 will move it down 1 stud. p.CFrame = p.CFrame * CFrame.new(Vector3.new(0, -0.1, 0)) wait(0.1) -- Change the 0.1 to how fast you want it to go down. end
That way, you don't need velocity. And yes, you can check for Touched
events.
p.CFrame = p.CFrame * CFrame.new(Vector3.new(0, -4, 0))
Was taken from a for loop here's the full code
for i = 1 , 150 do d.Transparency = d.Transparency + 0 d.CFrame = d.CFrame * CFrame.new(Vector3.new(0, -2, 0)) p.CFrame = p.CFrame * CFrame.new(Vector3.new(0, -4, 0)) m.Scale = m.Scale - Vector3.new(0, 0.02, 0) wait() end
Also this script is cloned into p and it doesn't work so that's why I thought I need to change it to velocity, why won't this script work?
arrow = script.Parent damage = 4 function onTouched(hit) humanoid = hit.Parent:findFirstChild("Humanoid") if humanoid~=nil then humanoid.Health = humanoid.Health - damage wait() end if hit.Name == "Blast" or hit.Name == "BasePlate" then Effect = Instance.new("Part") Effect.Parent = game.Workspace Effect.Anchored = true Effect.CanCollide = false Effect.Size = Vector3.new(1, 1, 1) Effect.formFactor = "Symmetric" Effect.Transparency = 0 Effect.BrickColor = BrickColor.new("Institutional white") Effect.TopSurface = "Smooth" Effect.BottomSurface = "Smooth" EffectMesh = Instance.new("SpecialMesh") EffectMesh.Parent = Effect EffectMesh.MeshType = "Sphere" EffectMesh.Scale = Vector3.new(1, 1, 1) for i = 1 , 20 do Effect.CFrame = CFrame.new(hit.Position) EffectMesh.Scale = EffectMesh.Scale + Vector3.new(1, 1, 1) wait() end wait() end end arrow.Touched:connect(onTouched)