Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-3

How to make a raycast do damage in FE? [closed]

Asked by 6 years ago
Edited 6 years ago

Someone asked this question but it got taken down so I'm going to ask (and answer it) for him Hope this can help anyone reading this question.

Closed as Not Constructive by valchip and User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
-6
Answered by 6 years ago
Edited 6 years ago

First create a RemoteEvent in your gun and name it FireEvent

Second create a normal script (not a local script) in your gun

Third change your local script to this

1mouse.Button1Down:connect(function()
2    local ray = Ray.new(hole.CFrame.p, (mouse.Hit.p - hole.CFrame.p).unit * 300)
3    local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true)
4    script.Parent:WaitForChild("FireEvent"):FireServer(part, position)
5end)

Finally copy and paste this into your normal script

01script.Parent:WaitForChild("FireEvent").OnServerEvent:connect(function(player, part, position)
02    local beam = Instance.new("Part", game.Workspace)
03    beam.BrickColor = BrickColor.new("Bright red")
04    beam.FormFactor = "Custom"
05    beam.Material = "Neon"
06    beam.Transparency = 0.5
07    beam.Anchored = true
08    beam.Locked = true
09    beam.CanCollide = false
10 
11    local distance = (hole.CFrame.p - position).magnitude
12    beam.Size = Vector3.new(0.3, 0.3, distance)
13    beam.CFrame = CFrame.new(hole.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
14 
15    game:GetService("Debris"):AddItem(beam, 0.1)
View all 29 lines...
Ad