I need a bit of help as tween pausing in my raycasting script is heavily delayed, and it doesn’t stop the tween at all, but the raycasting does indeed hit the wall, any help?
Script:
local TS = game:GetService("TweenService")
local Part = script.Parent.Part
local FaceV = script.Parent.FaceVector
local RunService = game:GetService("RunService")
local Time = 0.3
local TSInfo = TweenInfo.new(
Time,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false
)
wait(5)
local Animation = TS:Create(Part, TSInfo, {CFrame = script.Parent.Z.CFrame; Size = script.Parent.Z.Size})
Animation:Play()
RunService.Stepped:Connect(function()
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {script.Parent}
Params.FilterType = Enum.RaycastFilterType.Blacklist
local Raycast = workspace:Raycast(Part.Position,FaceV.CFrame.LookVector * 5000, Params)
if Raycast then
local Distance = (Part.Position - Raycast.Position).Magnitude
local p = Instance.new("Part")
p.CanQuery = false
p.Anchored = true
p.CanCollide = false
p.Size = Vector3.new(0.1, 0.1, Distance)
p.CFrame = CFrame.lookAt(Part.Position, Raycast.Position)*CFrame.new(0, 0, -Distance/2)
p.Parent = workspace
if Distance <= Part.Size.Z /2 then
Animation:Pause()
Animation:Destroy()
if Raycast.Instance.Parent:FindFirstChild("Humanoid") then
print("hit")
Raycast.Instance.Parent.Humanoid:TakeDamage(5)
end
end
end
end)
Edits: Added a screenshot, and fixed some spelling mistakes.