How can i make my light beam attack always start in front of the character?
Sorry for the rough scripts, im fairly new, but what im trying to do is make a cylinder shaped object start in front of you and quickly expand outwards. my problem is that i cant figure out how to get it to go in front of you, and its always going across 1 of the axis.
Code for the local script that triggers the attack
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local UserInputService = game:GetService( "UserInputService" ) |
03 | local plr = game.Players.LocalPlayer |
04 | local Char = plr.Character or plr.CharacterAdded:Wait() |
05 | local Remote = ReplicatedStorage.Fired |
06 | local Mouse = plr:GetMouse() |
11 | UserInputService.InputBegan:Connect( function (Input, IsTyping) |
12 | if IsTyping then return end |
13 | local KeyPressed = Input.KeyCode |
14 | if KeyPressed = = Enum.KeyCode [ Key ] and Debounce and Char then |
16 | Remote:FireServer(Mouse.Hit) |
Code for the attack itself
01 | game.ReplicatedStorage.Fired.OnServerEvent:Connect( function (Player, Debounce) |
02 | local Character = Player.Character or Player.CharacterAdded:wait() |
04 | local LightBeam = Instance.new( "Part" ) |
05 | LightBeam.Name = "LightBeam" |
06 | LightBeam.Size = Vector 3. new( 3 , 3 , 3 ) |
07 | LightBeam.Shape = Enum.PartType.Cylinder |
08 | LightBeam.Material = Enum.Material.Neon |
09 | LightBeam.BrickColor = BrickColor.new( "Cool yellow" ) |
10 | LightBeam.CanCollide = false |
11 | LightBeam.Parent = Character |
12 | LightBeam.CFrame = Character.Torso.CFrame*CFrame.new( 0 , 1 , 0 ) |
13 | LightBeam.Anchored = true |
15 | LightBeam.Size = Vector 3. new( 104 , 3 , 104 ) |
the game is set up to only use r6 models btw