local gun = game.StarterPack.Gun1.Handle.CFrame local part = game.Workspace.beamtest.CFrame local Players = game:GetService("Players") local mouse = Players:GetMouse() Tool = game.StarterPack.Gun1 mouse.Button1Down:connect(function() local att0 = Instance.new('Attachment', part) local att1 = Instance.new('Attachment', gun) local beam = Instance.new("Beam") att0.Position = Vector3.new(gun) att1.Position = Vector3.new(part) att0.Parent = workspace.Terrain att1.Parent = workspace.Terrain beam.color = Color3.fromRGB(144,144,144) beam.Attachment0 = att0 beam.Attachment1 = att1 beam.Width0 = 0.2 -- starts small beam.Width1 = 2 -- ends big beam.Enabled = true beam.Parent = att0 end)
Sorry for the inconvenience about all the questions! Last question probably but why won't a beam appear?
first of all, you didnt set the Parent
of the Beam
so it wont appear, and you dont need to set the Position
of the beam. also the Equipped
event wont fire if the player clicks the mouse, it fires when the tool is equipped by the player the event you want is the Button1Down
event of the players mouse such as this example.
script.Parent.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() print("i have been clicked") end) end)
also your defining the player's mouse 2 times in your script as your doing a variable of the mouse and the parameter of the Equipped
event which is the players mouse.
local part = game.Workspace.beamtest local Players = game:GetService("Players").LocalPlayer local Tool = script.Parent local gun = script.Parent.Handle Tool.Equipped:Connect(function(mouse) -- :connect() is decaperated, use :Connect() mouse.Button1Down:Connect(function() local att0 = Instance.new('Attachment') local att1 = Instance.new('Attachment') local beam = Instance.new("Beam") beam.Color = Color3.fromRGB(144,144,144) beam.Attachment0 = att0 beam.Attachment1 = att1 beam.Width0 = 0.2 beam.Width1 = 2 att0.Parent = gun att1.Parent = part beam.Parent = workspace end) end)
and the parent arguement of Instance.new()
is decaperated, instead set the parent last, and i would also suggest using the players Backpack
instead of StarterPack
. theres alot more mistakes too