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

Make moving object immune to gravity?

Asked by 6 years ago
Edited 6 years ago

I have a union that I clone in a function that I want to go infinitey in the x or y positions based on where they clicked, but how do I make it not fall do to gravity?

fireWizardCallXOutFunction.OnServerEvent:connect(function(player,mouseHit)
    local lmbWaitTimeLeft = player.Backpack.PlayerData.InGameData.Cooldowns.LMBCooldown.Value   
    local lmbWaitTime = game.ReplicatedStorage.Info.Characters.FireWizard.LMBAttack.Attack2Cooldown.Value
    local torso = player.Character.HumanoidRootPart
    local xout = game.ServerStorage.XOut
    local xoutCopy = xout:Clone()
    xoutCopy.Parent = game.Workspace
    xoutCopy.Position = torso.Position
    xoutCopy.CFrame = player.Character:WaitForChild("HumanoidRootPart").CFrame
    xoutCopy.Velocity = mouseHit * 25
    player.Backpack.PlayerData.InGameData.Cooldowns.LMBCooldown.Value = lmbWaitTime

end)

Local Script Function:

local mouse = player:GetMouse();
mouse.Button1Down:connect(function()
    local lmbWaitTimeLeft = game.Players.LocalPlayer:WaitForChild("Backpack").PlayerData.InGameData.Cooldowns.LMBCooldown.Value 
    if lmbWaitTimeLeft == 0 and not xoutAttackCalled then
        xoutAttackCalled = true
        local mouseHit = mouse.Hit.lookVector
        local animation = game.Workspace.Animations.FireWizard.xoutAttackAnimation
        local trackAnimation = nil
        trackAnimation = player.Character.Humanoid:LoadAnimation(animation)
        player.Character.Humanoid.WalkSpeed = 0
        player.Character.Humanoid.JumpPower = 0
        trackAnimation:Play()       
        wait(2)
        fireWizardCallXOutFunction:FireServer(mouseHit)
        player.Character.Humanoid.WalkSpeed = 16
        player.Character.Humanoid.JumpPower = 50
        xoutAttackCalled = false
    end

end)
0
Enable Can Collide Leamir 3138 — 6y
0
You can't get the Mouse's Hit from the server only client. User#19524 175 — 6y
0
its passed in from a local script ItsArkum 42 — 6y
0
But you're defining it in a server. The client has a mouse but the server doesn't. The client handles user input and not the server. User#19524 175 — 6y
View all comments (12 more)
0
Its getting it fine, ill edit the post with the localscript function. The mousehit isn't the problem here.... ItsArkum 42 — 6y
0
The server doesn't handle user input and the mouse is user input! Why would you have the mouse's Hit in the server anyways! User#19524 175 — 6y
0
I get the user input from the local script and then pass in the numbers to the server. That is how parameters for a function work bud. I use the mouse hit to send the object in the direction that the mouse was when the button was click. If you read the code you wuold find that out. The fact you don't get function parameters means you don't have the qualifications to comment on this matter. ItsArkum 42 — 6y
0
PLUS if it DIDNT work then how come when I put a print(mouseHit) on the server side script it prints out the numbers of the mouse's position? ItsArkum 42 — 6y
0
again the server doesn't have the mouse. the client does. you're saying if a player moves their mouse one way all the clients mice will too? again you should learn about User input mainly ContextActionService and UserInputService :) noob User#19524 175 — 6y
0
But why have the server handle the mouse movement. You have to #1 tell the server you moved the mouse and #2 the server has to tell the clients to do blah blah blah and just a lot of lag and if you just handled the mouse in the localscript and only locally it would completely eliminate lag time. logic User#19524 175 — 6y
0
DUDE the server doesn't have the mouse, the mouseHit is a vector3 that is no longer connected to the mouse. All it is is a vector3 that I named mouseHit. It isn't the mouse itself NOOB ItsArkum 42 — 6y
0
I cannot create the part in the local script because the part would only show up for the one client, so I pass in the lookvector of the mouse so it renders 1 part going in the direction of the player that casted the attack ItsArkum 42 — 6y
0
AND ONCE AGAIN this is not the point of the question... if you can tell me how to make a moving object not fall because of gravity you would finally be helpful to the conversation ItsArkum 42 — 6y
0
mouse.Hit is a CFrame value, LOL User#19524 175 — 6y
0
Thats besides the point that you're wrong on the issue ItsArkum 42 — 6y
0
can't believe you're from 2012 and me from 2014 i know more. seems pged kid User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

The roblox wiki does a good job showing how to do this: http://wiki.roblox.com/index.php?title=Gravity

0
No it doesn't xXrawr_xdXxOwO 24 — 6y
0
Putting this script.Parent.BodyForce.force = Vector3.new(0, 196.2, 0)* script.Parent:GetMass() in a script in the part along with a bodyForce and setting the z velocity to 0 did it ItsArkum 42 — 6y
0
i mean Y ItsArkum 42 — 6y
0
What do you mean "No it doesn't" it gives you the script that negates the effects of gravity which is what he wanted justoboy13 153 — 6y
Ad

Answer this question