What do you want to achieve? Keep it simple and clear!
I want to size and position the cloned part to a start (Handle Part position) and end (raycast position). Let me draw this out so you have a better understanding of what I want!
Effect is the part. Here are the results
I don’t want it like this but I want it starting from the Handle Part and to the end of the raycast. Sized and Positioned Correctly! I have also searched on google for any help on doing this and I couldn’t find any!
Here is the whole code (server-script):
local TweenService = game:GetService("TweenService")
local tool = script.Parent
local Animation = tool:WaitForChild("GrappleAnim")
local Grapple = tool:WaitForChild("Grapple")
local Configuration = tool:WaitForChild("Configuration")
local MaxRange = Configuration.MaxRange
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.Out,
0,
false,
0
)
Grapple.OnServerInvoke = function(player, mouseRay)
local character = player.Character
local mouseOrigin = mouseRay.Origin
local mouseDirection = mouseRay.Direction * MaxRange.Value
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {character}
Params.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(mouseOrigin, mouseDirection, Params)
if raycastResult then
if raycastResult.Instance:IsA("Part") then
local hitPart = raycastResult.Instance
local Effect = script.Parent.Effect:Clone()
Effect.Parent = character
Effect.Position = raycastResult.Position
Effect.Size = Vector3.new(raycastResult.Position.X+tool.Handle.Position.X, Effect.Size.Y, Effect.Size.Z)
local tween = TweenService:Create(character.HumanoidRootPart, tweenInfo, {CFrame = CFrame.new(raycastResult.Position + Vector3.new(0,5,0))})
tween:Play()
return true, tween
end
end
return false
end
Hard to tell exactly what’s going on because I don’t know where your mouse is, but a few suggestions:
Make sure the default Effect.Size has small X and Y values. It doesn’t matter what the Z is, but your original code used a different axis for this so your X size might just be large.
Make sure the Effect is anchored and non-cancollide