Recently I've been trying to make a function that shoots an object towards a players mouse. It used to work fine in local scripts, but now, when I send the Mouse.Hit across to the server and try to make something move towards it it no longer works. I've tried many things but I always get the same result. The object just ends up flying somewhere else, no mouse input detected.
Here's the code:
**Client Side
plr = game.Players.LocalPlayer
repeat wait() until plr.Character~= nil
m = plr:GetMouse()
loaded = true
local mousep = m.Hit
m.KeyDown:connect(function(key)
key = key:lower()
if key == "x" and loaded == true then
loaded = false
workspace.Events.GravityRock:FireServer(mousep)
wait(8)
loaded = true
end
end)
**Server Side
workspace.Events.GravityRock.OnServerEvent:Connect(function(plr, mousep)
local anim = plr.Character.Humanoid:LoadAnimation(script.GravityRock)
anim:Play()
rock1.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(25,-4,0)
rock2.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(-25,-4,0)
rock3.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,-4,25)
rock4.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,-4,-25)
wait(0.3)
rock1.Anchored = false
rock2.Anchored = false
rock3.Anchored = false
rock4.Anchored = false
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1e8,1e8,1e8)
bv.Velocity = Vector3.new(0,80,0)
bv.Parent = rock1
local bv2 = Instance.new("BodyVelocity")
bv2.MaxForce = Vector3.new(1e8,1e8,1e8)
bv2.Velocity = Vector3.new(0,80,0)
bv2.Parent = rock2
local bv3 = Instance.new("BodyVelocity")
bv3.MaxForce = Vector3.new(1e8,1e8,1e8)
bv3.Velocity = Vector3.new(0,80,0)
bv3.Parent = rock3
local bv4 = Instance.new("BodyVelocity")
bv4.MaxForce = Vector3.new(1e8,1e8,1e8)
bv4.Velocity = Vector3.new(0,80,0)
bv4.Parent = rock4
wait(0.8)
bv:remove()
bv2:Remove()
bv3:remove()
bv4:remove()
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = mousep.lookVector * 50
bv.Parent = rock1
local bv2 = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = mousep.lookVector * 50
bv2.Parent = rock2
local bv3 = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = mousep.lookVector * 50
bv3.Parent = rock3
local bv4 = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = mousep.lookVector * 50
bv4.Parent = rock4
You can see here that on the Server Side, the rocks/objects are generated beneath the player, then fly up into the air, and then after that I insert new a BodyVelocity into the rocks that is supposed to follow the mouse. The problem is, it does no such thing.

1 comment
Thanks, but unfortunately the rocks still don't go towards the mouse. They just kind of drop wherever.