Hi!
-
What do you want to achieve? I want to make this projectile (using a force) go towards the mouse so when I look up it will go towards the mouse.
-
What is the issue? I can’t seem to figure out how to get it to look at the mouse directly. (I do have a script which aims my arm at the mouse, so I’d imagine it would translate over since its on the server.)
-
What solutions have you tried so far? I’ve tried setting the rotation of the part to be towards the arm which aims at the mouse.
Here’s my script:
-- Var
local WeaponsModule = require(game:GetService("ReplicatedStorage"):WaitForChild("Modules"):WaitForChild("Stats"):WaitForChild("Weapons"))
local Damage = WeaponsModule.Dictionary.Damage
local Force = WeaponsModule.Dictionary.Force
-- func
function throw(force,player,handleOrient)
script.Parent.ThrowSound:Play()
local book = game:GetService("ReplicatedStorage").Dictionary:Clone()
book.Parent = workspace.Debris
book.Orientation = handleOrient
book.Position = script.Parent.Parent.Head.Position + Vector3.new(0,1.5,0)
local attachment = Instance.new("Attachment",book)
book.Owner.Value = player.Name
local vforce = Instance.new("VectorForce")
vforce.Parent = book
vforce.Force = Vector3.new(force,0,0)
vforce.Attachment0 = attachment
vforce.ApplyAtCenterOfMass = true
wait(0.1)
vforce:Destroy()
end
-- init
script.Parent.Throw.OnServerEvent:Connect(function(player,handleOrient)
throw(Force,player,handleOrient)
end)
Client:
-- Variables
local OnThrow = script.Parent.Throw
local Cooldown = false
local CooldownLength = 2
local Self = game.Players.LocalPlayer
local char = Self.Character
local mouseP = Self:GetMouse().Hit.p
-- Functions
function click()
if Cooldown == false then
OnThrow:FireServer(script.Parent.Parent["Right Arm"].Orientation + Vector3.new(0,105,0))
Cooldown = true
wait(CooldownLength)
Cooldown = false
end
end
-- Init
script.Parent.Activated:Connect(click)
Instance Structure:
Video:
Thanks!