So, when the following code is in a normal script it works in studio but then when i take it to live game or team test, it doesnt even activate...
This is weird because i always thought u could use server scripts in a tool :(
note: it doesn't even print '1' in live game/team test
local tool = script.Parent local player = tool.Parent.Parent tool.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() print('1') local character = script.Parent.Parent print('2') local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300) print('3') local part, position = workspace:FindPartOnRay(ray, character, false, true) print('4') local beam = Instance.new('Part') beam.Parent = workspace beam.CanCollide = false beam.Anchored = true beam.Transparency = .25 beam.Material = 'Neon' local distance = (tool.Handle.CFrame.p - position).magnitude beam.Size = Vector3.new(0.3, 0.3, distance) beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0,0,-distance/2) beam.Touched:Connect(function(hit) if hit.Parent then local humanoid = hit.Parent:FindFirstChild('Humanoid') if humanoid then humanoid:TakeDamage(70) end end end) end) end)
---Maybe you can use activated connect for it local tool = script.Parent local player = game.Players.LocalPlayer
tool.Activated:Connect(function()
06 print('1')
07 local character = script.Parent.Parent
08 print('2')
09 local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
10 print('3')
11 local part, position = workspace:FindPartOnRay(ray, character, false, true)
12 print('4')
13 local beam = Instance.new('Part')
14 beam.Parent = workspace
15 beam.CanCollide = false
16 beam.Anchored = true
17 beam.Transparency = .25
18 beam.Material = 'Neon'
19 local distance = (tool.Handle.CFrame.p - position).magnitude
20 beam.Size = Vector3.new(0.3, 0.3, distance)
21 beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0,0,-distance/2)
22
23 beam.Touched:Connect(function(hit)
24 if hit.Parent then
25 local humanoid = hit.Parent:FindFirstChild('Humanoid')
26 if humanoid then
27 humanoid:TakeDamage(70)
28 end
29 end
30 end)
31 end)
32 end)