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

How can I make this work with Filtering Enabled?

Asked by
PWNTART 33
7 years ago

So I am working with the roblox raycast script on the wiki and ive been able to make a working gun however in multiplayer the Beam/bullet cant be seen by anyone but the player and damage is dealt locally so when shot players dont actually take damage and die.

local beam = Instance.new("Part", workspace)
        beam.BrickColor = BrickColor.new("Bright red")
        beam.FormFactor = "Custom"
        beam.Material = "Neon"
        beam.Transparency = 0.25
        beam.Anchored = true
        beam.Locked = true
        beam.CanCollide = false

        local distance = (tool.Handle.CFrame.p - position).magnitude
        beam.Size = Vector3.new(0.3, 0.3, distance)
        beam.CFrame = CFrame.new(tool.Muz.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)

        game:GetService("Debris"):AddItem(beam, 0.05)

                wait(.09)   

        if part then
            local humanoid = part.Parent:FindFirstChild("Humanoid")

            if not humanoid then
                humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
            end

            if humanoid then
                humanoid:TakeDamage(7.5)
                script.Parent.Hit:Play()

2 answers

Log in to vote
0
Answered by 7 years ago

Create a remoteevent which takes the argument of the mouses hit cframe and the tools cframe. Raycast from the server and when the mouse button is pressed, fire the event. Remember, you'll never learn if we just give you a script. Try doing this first and if you have future questions you can ask.

Ad
Log in to vote
0
Answered by 7 years ago

Instance.new("Part",workspace)

All that code must be ran on the server for other players to see it.

Use a remote event to do this.

Answer this question