So I built a pistol (with help from the wiki) that is basically a laser gun that reloads like a pistol. The only problem with it is when I try to change the mouse icon, it says "Image failed to load :: Unexpected URL" which basically breaks the script. I have no idea why it is doing this as it was working earlier. Script:
local tool = script.Parent
local user
local ammo = 12
local fireIco = 'rbxasset://textures/GunCursor.png'
local reloadingIco = 'rbxasset://textures/GunWaitCursor.png'
--when the tool is equipped
tool.Equipped:connect(function(mouse)
mouse.Icon = fireIco
--store the character of the person using the tool
user = tool.Parent
--when the left mouse button is clicked
mouse.Button1Down:connect(function()
if ammo ~= 0 then --make and do a hit test along the ray
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*300)
local hit, position = game.Workspace:FindPartOnRay(ray, user)
--do damage to any humanoids hit
local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
if humanoid then
if hit.Namee == "Head" then
humanoid:TakeDamage(10000000)
end
humanoid:TakeDamage(30)
end
--draw the ray
local distance = (position - tool.Handle.CFrame.p).magnitude
local rayPart = Instance.new("Part", user)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.Yellow()
rayPart.Transparency = 0.5
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.formFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance)
rayPart.CFrame = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)
--add it to debris so it disappears after 0.1 seconds
game.Debris:AddItem(rayPart, 0.1)
ammo = ammo - 1
else
for i = 1, 12 do
print("Insert reloading sounds here")
mouse.Icon = waitIco
end
mouse.Icon = fireIco
end
end)
end)
Any help would be fine.

1 comment
be more specific.