alright this has probably been posted before and i would think you would use CFrame but i’m having trouble getting a part to face me.
local RS = game:GetService("ReplicatedStorage") --gets rstorage
local A1 = RS:WaitForChild("A1") --finds the remote event
local toolOne = nil -- define your tools if needed
local debounce = false
A1.OnServerEvent:Connect(function(plr, tool) --catches the signal made from the input
print("fired event") --checks if the remote event fired
print(plr, tool) -- checks who gave the signal and what weapon they have
local plrChar = plr.Character --finds the signal giver's character
local findTool = plrChar:FindFirstChild(tool.Name) --finds the tool name
print(findTool) --double checks the tool name
if findTool == nil then
print("Player is not holding a weapon")
end
local SelectedTool = tostring(findTool) --Transfers the value of findTool (an instance) to SelectedTool (a string)
print(SelectedTool)
if not findTool then -- runs if there is no tool
print("tool not found")
return end
-- TOOL ABILITIES GO HERE
if SelectedTool == "Crusher" then --Runs if the player is holding Scythe
print("Move Successful!")
local attackDebounce = false
local h = plrChar:WaitForChild("Humanoid")
local animator = h:WaitForChild("Animator")
local hrp = plrChar:WaitForChild("HumanoidRootPart")
local rightLeg = plrChar:WaitForChild("Right Leg")
local level = plr:WaitForChild("Level")
local LookVector = hrp.CFrame.LookVector
local animToPlay = script:FindFirstChild("Animation")
local loadAnim = animator:LoadAnimation(animToPlay)
loadAnim:Play()
wait(.5)
local fissure = RS:WaitForChild("Fissure"):Clone()
fissure.Parent = workspace
-- Build a "RaycastParams" object
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {plrChar}
raycastParams.IgnoreWater = true
local maxDistance = 10
-- Cast the ray
local origin = hrp
local raycastResult = workspace:Raycast(origin.Position + Vector3.new(0,5,0), Vector3.new(30,-90,0).Unit * maxDistance, raycastParams)
-- Interpret the result
if raycastResult then
print("Object/terrain hit:", raycastResult.Instance:GetFullName())
print("Hit position:", raycastResult.Position)
print("Surface normal at the point of intersection:", raycastResult.Normal)
print("Material hit:", raycastResult.Material.Name)
fissure.Position = raycastResult.Position + (LookVector * 5)
else
print("Nothing was hit!")
end
local Blade = tool:WaitForChild("Hammer").Blade
local damage = 250 * (level.Value * 2.5)
Blade.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and attackDebounce == false then
hit.Parent.Humanoid:TakeDamage(damage)
attackDebounce = true
print(hit.Parent.Humanoid.Health)
end
end)
wait(3.3)
attackDebounce = false
damage = 0
end
if findTool == toolOne then
print("Player wants to do an action with this specific tool")
end
end)
this is the code in the hammer (using script)
again, this has probably been posted before but i would like to know how.