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

I am trying to create a light beam in a tool. Other people cant see it in the game?? help

Asked by 6 years ago
Edited 6 years ago

Help me here is the Local Script:

 local Tool = script.Parent
 local player = game:GetService("Players").LocalPlayer

 local en = true
Tool.Equipped:connect(function(mouse)
print("Tool equipped!")
if not en then return end
 en = false
Tool.RemoteEvent:FireServer(mouse.Hit)
wait(.5)
en = true

mouse.Button1Down:connect(function()
    print("Mouse pressed!")
    local ray = Ray.new(Tool.Handle.CFrame.p, (mouse.Hit.p - Tool.Handle.CFrame.p).unit * 300)
    local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)

    local beam = Instance.new("Part", workspace)
    beam.BrickColor = BrickColor.new("New Yeller")
    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(.5, .5, distance)
    beam.CFrame = CFrame.new(Tool.Handle.CFrame.p, position) * CFrame.new(0, 0,     -distance / 2)

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

    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(30)
        end
    end
    beam.Touched:Connect(function(hit)
        if not en then return end
 en = false

        for i = 1,10 do
            local Explosion = Instance.new("Part")
            Explosion.BrickColor = BrickColor.new("New Yeller")
            Explosion.Shape = Enum.PartType.Ball
            Explosion.Material = "Neon"
            Explosion.FormFactor = "Custom"
            Explosion.Transparency = 0.25
            Explosion.Size = Vector3.new(50,50,50)
            Explosion.CanCollide = false
            Explosion.Anchored = true
            Explosion.Locked = true
            Explosion.CFrame = beam.CFrame
            Explosion.Parent = game.Workspace
            game.Debris:AddItem(Explosion,1)
            wait(0.005)
            Explosion.Size = Vector3.new(55,55,55)
            wait(0.005)
            Explosion.Size = Vector3.new(58,58,58)
            wait(0.005)
            Explosion.Size = Vector3.new(60,60,60)
            wait(0.005)
            Explosion.Size = Vector3.new(65,65,65)
            wait(0.005)
            Explosion.Size = Vector3.new(70,70,70)
            wait(0.005)
            Explosion.Size = Vector3.new(75,75,75)


            wait()
            en = true

        end

    end)
end)
end)

I have a remote event in the tool too. its kind of based off of kizaru's finger blast. Appreciated.

0
sorry the script didnt really go in one thing...... SplendidKyle567 8 — 6y
0
I am really pround of it SplendidKyle567 8 — 6y
0
Turn it into a script and use Tool.Activated instead of mouse.Button1Down, https://www.robloxdev.com/api-reference/event/Tool/Activated Vulkarin 581 — 6y
0
Also I don't think it should be a local script. Starnamics 24 — 6y
View all comments (3 more)
0
so i should put it into normal script?? SplendidKyle567 8 — 6y
0
what about in the top where it says Tool.RemoteEvent:FireServer(mouse.Hit) wait(.5) en = true SplendidKyle567 8 — 6y
0
i dont have player1 in players, what do i do? SplendidKyle567 8 — 6y

Answer this question