Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Detect = coroutine.wrap(function()
- Player = game.Players.LocalPlayer
- mouse = Player:GetMouse()
- mouse.Button1Down:connect(function()
- MouseDown = true
- end)
- mouse.Button1Up:connect(function()
- MouseDown = false
- end)
- end)
- Detect()
- Player = game.Players.LocalPlayer
- mouse = Player:GetMouse()
- game:GetService('RunService').RenderStepped:connect(function()
- if Player.Character:FindFirstChild("Tool") then
- if MouseDown == true then
- if mouse.Target.Name == "WoodSection" then
- targetWood = mouse.Target
- Tool=Player.Character.Tool
- ---FaceVector
- Height = targetWood.CFrame:pointToObjectSpace(mouse.Hit.p).Y + targetWood.Size.Y/2
- local ray = Ray.new(Player.Character.Head.Position, ((targetWood.CFrame * CFrame.new(0, Height - targetWood.Size.Y/2, 0)).p - Player.Character.Head.Position).unit * 200)
- part,_,p = workspace:FindPartOnRay(ray, Player.Character)
- function fixVector(V)
- return Vector3.new(math.floor(V.X + 0.5), math.floor(V.Y + 0.5), math.floor(V.Z + 0.5))
- end
- local faceVector = fixVector(targetWood.CFrame:vectorToObjectSpace(p))
- if faceVector.Y ~= 0 then
- return
- end
- local lookAtCFrame = CFrame.new(Player.Character.Head.Position, mouse.Hit.p)
- local relativeCFrame = lookAtCFrame:toObjectSpace(targetWood.CFrame * CFrame.Angles(math.pi/2, 0, 0))
- local relativeLookVector = relativeCFrame.lookVector
- local m = relativeLookVector.Y >= 0 and 1 or -1
- if faceVector.X == 1 then
- faceVector = Vector3.new(0, 0, -1) * m
- elseif faceVector.X == -1 then
- faceVector = Vector3.new(0, 0, 1) * m
- elseif faceVector.Z == 1 then
- faceVector = Vector3.new(1, 0, 0) * m
- elseif faceVector.Z == -1 then
- faceVector = Vector3.new(-1, 0, 0) * m
- end
- local cutEvent = targetWood.Parent.CutEvent
- game.ReplicatedStorage.Interaction.RemoteProxy:FireServer(cutEvent, {sectionId = targetWood.ID.Value, faceVector = faceVector, height = Height, hitPoints = 0.2, cooldown = 0, cuttingClass = "Axe", tool = Player.Character.Tool})
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement