Equipped Tool Not Valid Member Of Player [SOLVED]

  1. What do you want to achieve? Keep it simple and clear!
    After I equip a tool, as in get it from the backpack inventory onto my player, I want to click on a part and have my tools Decal.Texture copied to the clicked parts Decal.Texture.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that the Decal.Texture will not copy over because the tool is not detected on my players even though it is equipped. The error message says "Picture is not a valid member of Model “Workspace.AneTChrist.” The “Picture” is my the name of the tool btw.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried to use :WaitForChild(“Picture”) and it has worked but it only works AFTER i put the picture back into my backpack and then take it back out. I want to simply be able to click the part with my tool equipped so that my tool’s decal texture is copied to the part’s decal texture.

Here is the script inside my part that I want to copy my tool’s decal:

local PicturePlacement = script.Parent
local rep = game:GetService("ReplicatedStorage")

PicturePlacement.ClickDetector.MouseClick:Connect(function(player)
	if player then
		PicturePlacement.Decal.Texture = player.Character.Picture.Handle.Decal.Texture
		print("Placed Picture")
	end
end)
1 Like

Couldn’t you get the asset ID then apply it like that?

You can get the tool reliably like this:

return player.Character:FindFirstChild("Picture") or player.Backpack:FindFirstChild("Picture")

But if you want it so it only works while it’s equipped, use this:

if player.Character:FindFirstChild("Picture") then
	PicturePlacement.Decal.Texture = player.Character.Picture.Handle.Decal.Texture
	print("Placed Picture")
end
1 Like

I could but I want the part to also be able to copy the decal texture of other tools. So i cant add a specific asset id into the script because then it would always have the same decal when I click it instead of changing to match the one of the tool I am holding.

I tried this but it didn’t even print “Paced Picture” so I don’t think it’s working. :confused: I will keep trying to use :FindFirstChild and see if that works out if I just keep moving it around to different parts of the script!

I’ve tried and I don’t think it’s possible to use a ClickDetector when having something equipped.

I’ll continue to try find a solution.

Omg wait that might be it- I didn’t even think about it but I think I had seen this was an issue before. I’ll look into it to, thanks!

You can get the player’s mouse on the client side and then if mouse.Target == PicturePlacement when they click, you can send a remote event to change the decal for everyone.

1 Like

Yeah i just saw this suggestion too! I’ll try to work with it this way and see if it works, thanks sm! I’ll get back to you once I test it out.

1 Like

Ok so i added this local script to my tool that’s in my replicatedstorage and it works BUT the issue now is that it copies the tool decal to the part decal no matter where on the screen I click. I tried to use what you gave me and do mouse.Target == PicturePlacement but I wasn’t sure where in the script to put it to make it work.

local PicturePlacement = game.Workspace.PicturePlacement1
local Picture = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

local function onButton1Down(player)
	PicturePlacement.Decal.Texture = Picture.Handle.Decal.Texture
end
mouse.Button1Down:Connect(onButton1Down)
local PicturePlacement = game.Workspace.PicturePlacement1
local Picture = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

local function onButton1Down(player)
   if mouse.Target == PicturePlacement then
	   PicturePlacement.Decal.Texture = Picture.Handle.Decal.Texture
   end
end
mouse.Button1Down:Connect(onButton1Down)
1 Like

This worked! i had JUST figured it out too lol, sorry- I’m still new to scripting. The only issue I have now is having it work on the server since the tool script is a local script. But now that it actually copies I hope it won’t be too hard from here.

1 Like

Do something like this:

Event.OnServerEvent:Connect(function()
    PicturePlacement.Decal.Texture = Picture.Handle.Decal.Texture
end)

Just be sure to fire the event from the local script and it should all work.

I need to make a server script though right? I still struggle with scripting server-client interactions with remote events/functions.

Yes, you do.

Take a look at this link for some info on RemoteEvents.

If you still need help after this, I can write you up a quick script.

1 Like

I read through the script examples and stuff but idk what Im doing tbh. I can get it copied on the client but I still can’t get it to copy on th server too so other players could see the change.

Client:

local PicturePlacement = game.Workspace.PicturePlacement1
local Picture = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

local Event = EVENTLOCATIONHERE

local function onButton1Down(player)
   if mouse.Target == PicturePlacement then
	   Event:FireServer()
   end
end
mouse.Button1Down:Connect(onButton1Down)

Server:

local Event = EVENTLOCATIONHERE

local PicturePlacement = game.Workspace.PicturePlacement1

Event.OnServerEvent:Connect(function(Player)
    local Picture = Player.Character:FindFirstChild("Picture")

     if Picture then
       PicturePlacement.Decal.Texture = Picture.Handle.Decal.Texture
   end
end)
1 Like

Omg thank youuuu it worked! My server script was wrong. I’ll mark your other response as the solution since my initial problem was not being able to detect the tool! Thanks for helping me with both things though c:

1 Like

Glad to hear it, have a good day!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.