Im having a problem with mouse.lookvector
The Client Script
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local PlayerFolder = character:WaitForChild("PlayerFolder")
local PlayerWelds = character:WaitForChild("PlayerWelds")
local Key = script.Keybind.Value
local active = false
local debounce = false
local cooldown = 2
UserInputService.InputBegan:Connect(function(Input ,IsTyping)
if IsTyping then return end
if (Input.KeyCode == Enum.KeyCode[Key]) then
if debounce == false and active == false then
debounce = true
game.ReplicatedStorage.FireBallEvent:FireServer(active,PlayerFolder,PlayerWelds)
end
end
end)
UserInputService.InputEnded:Connect(function(Input)
if (Input.KeyCode == Enum.KeyCode[Key]) then
if debounce == true and active == false then
active = true
game.ReplicatedStorage.FireBallEvent:FireServer(active, PlayerFolder, Mouse.Hit)
end
end
end)
game.ReplicatedStorage.FireBallEvent.OnClientEvent:Connect(function()
wait(cooldown)
debounce = false
active = false
end)
The Server Script
local RepStorage = game:GetService("ReplicatedStorage")
local Projectiles = RepStorage.Projectiles
local RightHand = nil
local holdanimTrack = nil
local holdAnim = nil
local InnerFireBall = nil
local mainWeld = nil
game.ReplicatedStorage.FireBallEvent.OnServerEvent:Connect(function(Player, active, PlayerFolder, PlayerWelds, PlayerBodyMovers)
if active == false then
local char = Player.Character
local dmg = char:FindFirstChild("dmgValue")
local Humanoid = char:FindFirstChild("Humanoid")
RightHand = char:FindFirstChild("RightHand")
holdAnim = Instance.new("Animation",PlayerFolder)
holdAnim.AnimationId = "rbxassetid://4885604627"
holdAnim.Parent = PlayerFolder
holdanimTrack = Humanoid:LoadAnimation(holdAnim)
holdanimTrack:Play()
InnerFireBall = Projectiles:WaitForChild("Inner"):Clone()
InnerFireBall.Size = Vector3.new(0.1,0.1,0.1)
InnerFireBall.Parent = PlayerFolder
InnerFireBall.CFrame = RightHand.CFrame * CFrame.new(0,-0.5,0)
mainWeld = Instance.new("Weld")
mainWeld.Part0 = RightHand
mainWeld.Part1 = InnerFireBall
mainWeld.C0 = RightHand.CFrame:Inverse()
mainWeld.C1 = InnerFireBall.CFrame:Inverse()
mainWeld.Name = "InnerFireBallWeld"
mainWeld.Parent = PlayerWelds
for fireballsizecount = 1,60,1 do
InnerFireBall.Size = InnerFireBall.Size + Vector3.new(0.03,0.03,0.03)
wait(0.1)
end
end
end)
game.ReplicatedStorage.FireBallEvent.OnServerEvent:Connect(function(Player, active, PlayerFolder, PlayerWelds, PlayerBodyMovers, Mouse)
if active == true then
local char = Player.Character
local Humanoid = char:WaitForChild("Humanoid")
holdanimTrack:Stop()
holdAnim:Destroy()
local releaseAnim = Instance.new("Animation",PlayerFolder)
releaseAnim.AnimationId = "rbxassetid://4890399550"
local releaseAnimTrack = Humanoid:LoadAnimation(releaseAnim)
releaseAnimTrack:Play()
mainWeld:Destroy()
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyVelocity.Velocity = Mouse.lookVector*30
BodyVelocity.Parent = InnerFireBall
game.ReplicatedStorage.FireBallEvent:FireClient(Player)
end
end)

1 comment
LookVector is a property of CFrame that represents the direction of the lookvector.