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

Why wont my custom mouse image load?

Asked by
Mr_Unlucky 1085 Moderation Voter
6 years ago

Whenever I make it so that the mouse icon changes correspondingly to when the gun is equipped or when it's reloading, it shows an error saying that it failed to load. Why is it doing that? Has anyone else experienced this?

--MADE BY MR_UNLUCKY
local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local Reload = tool.Reload
local Shoot = tool.Shot 
local GUI = tool.ScreenGui
local damageBODY = 10
local damageHEAD = 30
local Equip = tool.Equip
local bullets = 15
local Players = game:GetService("Players")
local mouse = game.Players.LocalPlayer:GetMouse()
tool.Equipped:connect(function(mouse)
    print("Tool equipped!")
    local newGUI = GUI:Clone()
    newGUI.Parent = Players.LocalPlayer.PlayerGui
    Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Bullets.Text = "Bullets:"..bullets..""
    Players.LocalPlayer.PlayerGui.ScreenGui.Frame.GunName.Text = tool.Name
    mouse.Icon = "http://www.roblox.com/asset?id=936803887"
    mouse.Button1Down:connect(function()
        if bullets <= 0 then
            Reload:Play()
            mouse.Icon = "http://www.roblox.com/asset?id=43557168"
            Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Bullets.Text = "RELOADING"
            wait(3.2)
            bullets = 15    
            Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Bullets.Text = "Bullets:"..bullets..""
            mouse.Icon = "http://www.roblox.com/asset?id=936803887"
        else
        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("Medium stone grey")
            beam.FormFactor = "Custom"
            beam.Material = "Metal"
            beam.Transparency = 0.25
            beam.Anchored = true
            beam.Locked = true
            beam.CanCollide = false
            bullets = bullets - 1
            print(bullets)
            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)
            Shoot:Play()        
            game:GetService("Debris"):AddItem(beam, 0.1)
            Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Bullets.Text = "Bullets:"..bullets..""
            if part then
            local rightLeg = part.Parent:FindFirstChild("RightLeg")
            local leftLeg = part.Parent:FindFirstChild("LeftLeg")
            local rightArm = part.Parent:FindFirstChild("RightArm")
            local leftArm = part.Parent:FindFirstChild("LeftArm")
            local torso = part.Parent:FindFirstChild("Torso")
            local head = part.Parent:FindFirstChild("Head")
            local humanoid = part.Parent:FindFirstChild("Humanoid")
            if not rightLeg or leftLeg or rightArm or leftArm or torso or head then
                local rightLeg = part.Parent:FindFirstChild("RightLeg")
                local leftLeg = part.Parent:FindFirstChild("LeftLeg")
                local rightArm = part.Parent:FindFirstChild("RightArm")
                local leftArm = part.Parent:FindFirstChild("LeftArm")
                local torso = part.Parent:FindFirstChild("Torso")
                local head = part.Parent:FindFirstChild("Head")
            end
            if rightLeg or leftLeg or rightArm or leftArm or torso then
                humanoid:TakeDamage(damageBODY)
            end
            if head then
                humanoid:TakeDamage(damageHEAD)
            end
end
end
tool.Unequipped:connect(function(mouse)
    Players.LocalPlayer.PlayerGui:FindFirstChild("ScreenGui"):Destroy()
end)
    end)
    end)
0
You're using decal ids while you should be using image ids Amiaa16 3227 — 6y

1 answer

Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

As I said in my comment, you are using decal ids while you should use image ids.

I was on phone so I couldn't really fix your code but now I can, so here it is:

--MADE BY MR_UNLUCKY
local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local Reload = tool.Reload
local Shoot = tool.Shot 
local GUI = tool.ScreenGui
local damageBODY = 10
local damageHEAD = 30
local Equip = tool.Equip
local bullets = 15
local Players = game:GetService("Players")
local mouse = game.Players.LocalPlayer:GetMouse()
tool.Equipped:connect(function(mouse)
    print("Tool equipped!")
    local newGUI = GUI:Clone()
    newGUI.Parent = Players.LocalPlayer.PlayerGui
    Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Bullets.Text = "Bullets:"..bullets..""
    Players.LocalPlayer.PlayerGui.ScreenGui.Frame.GunName.Text = tool.Name
    mouse.Icon = "rbxassetid://936803874" --the image id of the decal is 936803874
    mouse.Button1Down:connect(function()
        if bullets <= 0 then
            Reload:Play()
            mouse.Icon = "rbxassetid://43557167" --the image id of the decal is 43557167
            Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Bullets.Text = "RELOADING"
            wait(3.2)
            bullets = 15    
            Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Bullets.Text = "Bullets:"..bullets..""
            mouse.Icon = "rbxassetid://936803887" --the image id of the decal is 936803887
        else
        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("Medium stone grey")
            beam.FormFactor = "Custom"
            beam.Material = "Metal"
            beam.Transparency = 0.25
            beam.Anchored = true
            beam.Locked = true
            beam.CanCollide = false
            bullets = bullets - 1
            print(bullets)
            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)
            Shoot:Play()        
            game:GetService("Debris"):AddItem(beam, 0.1)
            Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Bullets.Text = "Bullets:"..bullets..""
            if part then
            local rightLeg = part.Parent:FindFirstChild("RightLeg")
            local leftLeg = part.Parent:FindFirstChild("LeftLeg")
            local rightArm = part.Parent:FindFirstChild("RightArm")
            local leftArm = part.Parent:FindFirstChild("LeftArm")
            local torso = part.Parent:FindFirstChild("Torso")
            local head = part.Parent:FindFirstChild("Head")
            local humanoid = part.Parent:FindFirstChild("Humanoid")
            if not rightLeg or leftLeg or rightArm or leftArm or torso or head then
                local rightLeg = part.Parent:FindFirstChild("RightLeg")
                local leftLeg = part.Parent:FindFirstChild("LeftLeg")
                local rightArm = part.Parent:FindFirstChild("RightArm")
                local leftArm = part.Parent:FindFirstChild("LeftArm")
                local torso = part.Parent:FindFirstChild("Torso")
                local head = part.Parent:FindFirstChild("Head")
            end
            if rightLeg or leftLeg or rightArm or leftArm or torso then
                humanoid:TakeDamage(damageBODY)
            end
            if head then
                humanoid:TakeDamage(damageHEAD)
            end
end
end
tool.Unequipped:connect(function(mouse)
    Players.LocalPlayer.PlayerGui:FindFirstChild("ScreenGui"):Destroy()
end)
end)
end)
Ad

Answer this question