Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm making an axe, but there's an error, output says '(expected Vector3, got CFrame)' ?

Asked by 5 years ago
Edited 5 years ago
local exampleModel_tree1 = workspace.exampleModel_tree1
tool = script.Parent
local localScriptText_testing = workspace.localScriptText_testing
local SurfaceGui = localScriptText_testing.SurfaceGui
local TextLableMessageOutput = SurfaceGui.TextLabel
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local HumanoidRootPart = workspace[player.Name].HumanoidRootPart
tool.Equipped:Connect(function()
   TextLableMessageOutput.Text = "tool was equipped"
    tool.Activated:Connect(function()
      TextLableMessageOutput.Text = "mouse was clicked"
      if mouse.Target and mouse.Target.Parent then
         if mouse.Target.CFrame == exampleModel_tree1.tree1Part1_trunk.CFrame and not HumanoidRootPart.**Position **<= exampleModel_tree1.tree1Part1_trunk.CFrame + CFrame.new(1,0,0 or 2,0,0 or 3,0,0) then
      if HumanoidRootPart.**Position** <= exampleModel_tree1.tree1Part1_trunk.CFrame +  CFrame.new(1,0,0 or 2,0,0 or 3,0,0) then
         TextLableMessageOutput.Text = "Clicked da tree but ya need to be closer to cut                        it"
      end
            TextLableMessageOutput.Text = "Clicked da tree"
            exampleModel_tree1.HitValue.Value = exampleModel_tree1.HitValue.Value - 1 
            if exampleModel_tree1.HitValue.Value <=0 then
         exampleModel_tree1.tree1Part1_trunk.Anchored = false
         TextLableMessageOutput.Text = "Tree successfully cut down"
         wait(2)
         exampleModel_tree1:Remove()
            end
         end
      end
   end)
end)
0
The code you have posted seems to have parts of highlighted. Could you post the exact code you're using without any annotations, so that it would be easier to read? gskw 1046 — 5y

1 answer

Log in to vote
0
Answered by 3 years ago

It looks like you're mixing a CFrame with a position. A coordinate frame stores a position plus a rotational matrix. So you could just grab the .Position from the CFrames, and that should fix it. So (exampleModel_tree1.tree1Part1_trunk.CFrame + CFrame.new(1,0,0 or 2,0,0 or 3,0,0)).Position instead.

Ad

Answer this question