PlayerGui is not a valid member of Mouse "Instance"

Hello, I basically wanted to make when you equip the the tool it will change a decal ID, but i keep getting this error: PlayerGui is not a valid member of Mouse “Instance”

Here’s the code:

script.Parent.Equipped:Connect(function(player)
	player.PlayerGui.Stats.ToolIcon.Decal.Texture = "http://www.roblox.com/asset/?id=6233227834"
end)

Thanks.

tool.Equipped returns the mouse and not the player that is the problem,

now given that this is in a local script as the mouse cant be gotten by the server you can use

script.Parent.Equipped:Connect(function(mouse)
	game:GetService("Players").LocalPlayer.PlayerGui.Stats.ToolIcon.Decal.Texture = "http://www.roblox.com/asset/?id=6233227834"
end)

in a local script (that is in either the player gui, tools, or player character,(i might be missing some)) you get the player with Players.LocalPlayer (with players being the player service)

yeah but how am i supposed to change the decal id now if it’s mouse.

Just use the script he so kindly provided you with. :slightly_smiling_face:

Yeah but how am i supposed to change the decal id if it’s “mouse”

In @56ytr56’s script, it isn’t. It gets the local player, and throws the mouse variable into the deep dark world of nil as it is not used at all, and neither should you.

Oh wait, i’m blind sorry. I didn’t see it

Yeah but now i get this: Players.ApeRuss.Backpack.Glock.Icon:2: attempt to index nil with ‘PlayerGui’

make sure the code is in a local script

I dont really see what could be the problem but I guess you could use a waitforchild

script.Parent.Equipped:Connect(function(mouse)
	game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui").Stats.ToolIcon.Decal.Texture = "http://www.roblox.com/asset/?id=6233227834"
end)

Ok it works now with this code but it doesn’t load the image for some reason,

script.Parent.Equipped:Connect(function(mouse)
	game:GetService("Players").LocalPlayer.PlayerGui.Stats.ToolIcon.Image = "rbxassetid://6233227834"
end)

And the decal itself isn’t moderated

the best thing i can think of is there is an error, now I’m not 100% sure how to check for errors but try placing it in a pcall to see if it returns any errors

script.Parent.Equipped:Connect(function(mouse)
local s, err = pcall(function()
	game:GetService("Players").LocalPlayer.PlayerGui.Stats.ToolIcon.Image = "rbxassetid://6233227834"
end)
if not s then
warn(err)
end
end)

now I’m not 100% sure if this will work but it should warn if there were any errors

It has no errors, but it doesn’t load the pic again…

well im not really sure what exactly is wrong in this situation, can you show me the link to the decal because i cant really tell if there was a typo

https://www.roblox.com/library/6233227834/PistolVC

alright so i dont see any typos yet so I dont know what exactly is wrong, you could of course add the waitforchild but i dont think it’ll do anything at this point, also you may remove the pcall as its not going to do much

The issue is that you’re trying to load a decal ID onto an image asset. You’ll need to insert a decal onto a random part in workspace, then copy that decal ID and paste it into that decal Instance. Then, grab the new rbxassetid you got and insert it into your script.

I don’t get what you’re saying, can you explain it in more details maybe, i will go walk y dog so i will respond bit later.