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

Missile freezes, is there a way to make it move smoother?

Asked by
Invisum -5
7 years ago
Edited 7 years ago

I am trying to make the classic superball lag less when it moves. Since it's not anchored and it needs to bounce, the current script is using missile.velocity to make it move. Would a body force or a body velocity actually make it move smoother? This is because for large places with lots of players the missile freezes. This is the code:

Tool = script.Parent

function fire(v)

    Tool.Handle.Boing:play()

    local vCharacter = Tool.Parent
    local vPlayer = game.Players:playerFromCharacter(vCharacter)

    local missile = Instance.new("Part")



    local spawnPos = vCharacter.PrimaryPart.Position



    spawnPos  = spawnPos + (v * 5)

    missile.Position = spawnPos
    missile.Size = Vector3.new(2,2,2)
    missile.Velocity = v * 200
    missile.BrickColor = BrickColor.random() -- BrickColor.new(26)
    missile.Shape = 0
    missile.BottomSurface = 0
    missile.TopSurface = 0
    missile.Name = "Cannon Shot"
    missile.Elasticity = 1
    missile.Reflectance = .2
    missile.Friction = 0

    Tool.Handle.Boing:clone().Parent = missile



    local new_script = script.Parent.CannonBall:clone()
    new_script.Disabled = false
    new_script.Parent = missile

    local creator_tag = Instance.new("ObjectValue")
    creator_tag.Value = vPlayer
    creator_tag.Name = "creator"
    creator_tag.Parent = missile



    missile.Parent = game.Workspace

end



Tool.Enabled = true
function onActivated()

    if not Tool.Enabled then
        return
    end

    Tool.Enabled = false

    local character = Tool.Parent;
    local humanoid = character.Humanoid
    if humanoid == nil then
        print("Humanoid not found")
        return 
    end

    local targetPos = humanoid.TargetPoint
    local lookAt = (targetPos - character.Head.Position).unit

    fire(lookAt)

    wait(2)

    Tool.Enabled = true
end


script.Parent.Activated:connect(onActivated)


0
can you show you script as well (edit question and press lua button and put your code inbetween the ~~ ) abnotaddable 920 — 7y
0
I've added the code. Note that this code was written by ROBLOX 11 years ago. Invisum -5 — 7y
0
Yes. Bodyforces are the way to go, instead of making a while wait(0.000000001) do loop to get the same effect. hiimgoodpack 2009 — 7y

Answer this question