how would i make a Part fire towards the mouse with FE on?
local bv = Instance.new("BodyVelocity", CylinderMesh.Parent) bv.velocity = CFrame.new(CylinderMesh.Parent.Position, Mouse.Hit.p).lookVector*85 bv.maxForce = Vector3.new(math.huge, math.huge, math.huge)
This is in a remote event in a server script
Mouse is defined in a local script that fires the remote event containing this code while passing Mouse
which is a variable for Mouse = Player:GetMouse()
that only works in Studio because for some reason in online the Mouse is nil.
I already tried to pass Mouse
as Mousey = Player:GetMouse()
Mouse = Mousey.Hit
and changed the code to
local bv = Instance.new("BodyVelocity", CylinderMesh.Parent) bv.velocity = CFrame.new(CylinderMesh.Parent.Position, Mouse.p).lookVector*85 bv.maxForce = Vector3.new(math.huge, math.huge, math.huge)
but When I change it to this it doesnt work properly in both studio and online. Halp plz
Hello there! You must put a LocalScript on the Player's character in workspace, with a tool, on the player's script (Starterplayer > scripts) or in a GUI in the player's PlayerGui, then do this:
local Player = Game.Players.LocalPlayer --Defines the Player, LocalScripts can call for a LocalPlayer (the player who 'holds' the LS. local Mouse = Player:GetMouse() --Sets the 'Mouse' variable to the LocalPlayer's mouse.
Further reading/references
http://wiki.roblox.com/index.php?title=API:Class/Player/GetMouse
http://wiki.roblox.com/index.php?title=API:Class/Mouse
It works, I assure.