So basically I'm trying to make it so if I click on a block with a hammer it checks if the player that's clicking is the owner of the block here's what I have:
local tool = script.Parent local player = game.Players.LocalPlayer local mouse = player:GetMouse() local function onActivate() local clickLocation = mouse.Hit if clickLocation.values.ownervalue.Value == 'DrGigaByte' then clickLocation:Destroy() end end tool.Activated:connect(onActivate)
I'm getting an error saying " values is not a valid member of CFrame" is there any way I could access the hit part and destroy it?
The only thing you are doing wrong is you are using "Mouse.Hit" which specifies what position the mouse is pointing to and I believe in which direction, but you want to know what object the mouse is pointing to, so you have to use the "Mouse.Target" event that will specify which block/basepart the mouse is currently pointing at.
The only thing you have to do Is change a line in your script, here, I did that for you, I also replaced "clickLocation" to "clickObject" cause that suits it a little bit better.
local tool = script.Parent local player = game.Players.LocalPlayer local mouse = player:GetMouse() local function onActivate() local clickObject = mouse.Target if clickObject.values.ownervalue.Value == 'DrGigaByte' then clickObject:Destroy() end end tool.Activated:connect(onActivate)