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.
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.
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)
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
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. 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!
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.
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)
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.
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.
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)
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: