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

SetNetworkOwner adding a gravity effect?

Asked by 5 years ago
function fire(vTarget)

    local vCharacter = Tool.Parent;

    if vHandle == nil then
        print("Handle not found")
        return 
    end
    local dir = HRT.CFrame.lookVector
    --dir = computeDirection(dir)

    local missile = Rocket:clone()

    local pos = HRT.Position + (dir * 5)
    local EggY = HRT.Orientation.Y
    missile.Position = pos
    missile.CFrame = CFrame.new(pos,  pos + dir)
    missile.Orientation = Vector3.new(0, EggY, 0)

    local bodyForce = Instance.new('BodyForce', Rocket)
    bodyForce.Name = 'Antigravity'
    bodyForce.force = Vector3.new(0, Rocket:GetMass(), 0)

    local vPlayer = game.Players:playerFromCharacter(vCharacter)

    if vPlayer == nil then
        print("Player not found")
    else

    end

    missile.RocketScript.Disabled = false

    missile.Parent = game.Workspace

    missile:SetNetworkOwner(vPlayer)

    local CreatorTag = missile.CreatorTag
    vPlayer = CreatorTag.Value

    SpawnPart.ParticleEmitter.Rate = (200)
    wait(0.01)
    SpawnPart.ParticleEmitter.Rate = (0)    


end

The script above is for a rocket launcher in my game that had issues with the rocket not flying smoothly. I found out it was because of the Network Owner issue. So I added the SetNetworkOwner line at 36 and it flies perfectly smoothly now. However, after adding that line, the rocket seems to have gravity. I have no idea how changing the Network Owner could affect the rocket's actual flight, but it doesn't fly straight anymore. It falls as it flies, like gravity now applies to it, which didn't happen before. Any ideas?

0
:playerFromCharacter() should be :GetPlayerFromCharacter, :clone should be :Clone(). In addition, you don't need to add parenthesis around numbers(unless you like to do that). This doesn't really solve anything except fix things that are deprecated. Here's an article on deprecation and why methods/properties/classes get deprecated: https://www.robloxdev.com/articles/Deprecation  saSlol2436 716 — 5y
0
Well thanks for correcting those deprecated terms. I just took the anti gravity code from Roblox's standard rocket launcher and added them mine and it works. I think setting the rocket's NetworkOwner to the player takes it out of the client so gravity then applies to it. It works fine though. tygerupercut3 68 — 5y

Answer this question