Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Make moving object immune to gravity?

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)

16 comments

0

Enable Can Collide

0

You can't get the Mouse's Hit from the server only client.

0

its passed in from a local script

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.

0

Its getting it fine, ill edit the post with the localscript function. The mousehit isn't the problem here....

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!

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.

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?

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

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

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

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

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

0

mouse.Hit is a CFrame value, LOL

0

Thats besides the point that you're wrong on the issue

0

can't believe you're from 2012 and me from 2014 i know more. seems pged kid

1 answer

✓ Accepted answer

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

4 comments

0

No it doesn't

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

0

i mean Y

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

This discussion is preserved as it was. New answers, comments, and votes are closed.