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)
