Hello, I'm making btools. I'm wondering how do you get the part that the player clicked on? I want it so that when you click on the part, a decal appears on the part you clicked.
local tool = script.Parent
local function Texture2D(point)
local Texture2D = Instance.new("Decal")
Texture2D.Texture = "rbxassetid://6423847544"
Texture2D.Face = "Top"
Texture2D.Parent = point
end
local function onActivated()
local human = tool.Parent.Humanoid
Texture2D(human.TargetPoint)
end
tool.Activated:Connect(onActivated)
Update: @FirezDevv supplied me a script, but it doesn't work and he just suddenly left when I reported an error. Can anybody help? It's a server script is parented to a tool, and the error I get is "Workspace.UnityEngine.Texture2D.Script:15: attempt to index nil with 'GetMouse'".
local tool = script.Parent
local function Texture2D(point)
local Texture2D = Instance.new("Decal")
Texture2D.Texture = "rbxassetid://6423847544"
Texture2D.Face = "Top"
Texture2D.Parent = point
end
local function onActivated(mouseT)
local human = tool.Parent.Humanoid
Texture2D(mouseT)
end
game.Players:FindFirstChild(tool.Parent.Name):GetMouse().MouseButton1Down:Connect(function()
onActivated(game.Players:FindFirstChild(tool.Parent.Name):GetMouse().Target)
end)

9 comments
It's a server script. How do I use this?
Edited, there you go this will work with the server script
I got the error: Error: (11,2) Syntax error: Incomplete statement: expected assignment or a function call
Workspace.UnityEngine.Texture2D.Script:12: attempt to index nil with 'Target'
Workspace.UnityEngine.Texture2D.Script:15: attempt to index nil with 'GetMouse'
uhh
Wrong signal, 'MouseButton1Down', it's 'Button1Down'. Please fix that one-line, it's atrocious and should never, ever, be written again.
that doesn't help
When it's unequipped, the tool is in a folder called "Backpack".