So, I made a simulation of what the problem is here:
------------- Module&Service --------------
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
--------- TweenInfo ---------
local tweenInfo = TweenInfo.new(
10,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
local tweenGoal = {
Size = Vector3.new(94.45, 109.05, 109.05);
}
local debounce = false
--------- Function ---------
local function ShootFireBlock()
if debounce then return end
-- get player important instance
local char = player.Character
if char == nil then return warn("Character not spawn yet") end
local humanoid = char:WaitForChild('Humanoid')
local hmr = char:WaitForChild("HumanoidRootPart")
debounce = true
-- Set so player cant move
humanoid.WalkSpeed = 0
humanoid.JumpHeight = 0
hmr.Anchored = true
-- get the object to workspace
local object = Instance.new("Part")
object.Name = "object"
object.Anchored = true
object.CanCollide = false
object.Transparency = 0.5
object.Color = Color3.fromRGB(213,115,61)
object.Size = Vector3.new(1.889, 2.181, 2.181)
-- Create tween instance
local tween = TweenService:Create(object, tweenInfo, tweenGoal)
-- Move object to real place
local lookAt = (hmr.CFrame * CFrame.Angles(math.rad(180), 0, 0)).LookVector
local originCFrame = hmr.CFrame * CFrame.Angles(math.rad(180), 0, 0)
object.CFrame = originCFrame
object.Parent = workspace
--Play a tween
tween:Play()
-- Connect the object size change function
local connection
connection = object:GetPropertyChangedSignal("Size"):Connect(function()
local x = object.Size.X
local newPos = originCFrame:ToWorldSpace(CFrame.new(0,0,x))
object.CFrame = newPos
if x == 94.45 then
connection:Disconnect()
end
end)
-- region simulate start here
coroutine.wrap(function()
-- Every 1 second the simulation is showing
-- The corner block simulation also grown bigger every second
local times = 0
while wait(1) and times < 10 do
times += 1
local startVector = originCFrame:ToWorldSpace(CFrame.new(object.Size.X/2, object.Size.Y/2, 0)).Position
local endVector = originCFrame:ToWorldSpace(CFrame.new(-object.Size.X/2, -object.Size.Y/2, object.Size.Z)).Position
local region = Region3.new(startVector, endVector)
-- This block will continue to the bottom right of the player character
local partStart = Instance.new("Part")
partStart.Name = "Start" .. tostring(times)
partStart.Anchored = true
partStart.Position = startVector
partStart.Size = Vector3.new(times, times, times)
partStart.Parent = workspace
-- This block will continue to the top left of the player character (and also going forward)
local partEnd = Instance.new("Part")
partEnd.Name = "End" .. tostring(times)
partEnd.Anchored = true
partEnd.Position = endVector
partEnd.Size = Vector3.new(times, times, times)
partEnd.Parent = workspace
-- Simulate the region
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Transparency = 0.75
part.CFrame = region.CFrame
part.Size = region.Size
part.Parent = workspace
end
end)()
-- When tween completed, destroy all tween
tween.Completed:Wait()
tween:Destroy()
-- Delete main object
object:Destroy()
-- Set so player can move again
humanoid.WalkSpeed = 16
humanoid.JumpHeight = 7
hmr.Anchored = false
debounce = false
end
--------- Connection ---------
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.J then
ShootFireBlock()
end
end
end)
You can try putting this on the local script and pressing J button.
The fireball (block) with orange color will be coming out and it will get bigger (using tween) and the position changes every time the size changes so it can move forward in front of the player
(it might look over complicated but this is only a simulation of the real problem that I’ve faced in my game, that is why some of the code might look nonsense)
The big grey block with a bit of transparency represents the region simulation (which in my game will use as a hitbox). IT SHOULD GROW BIGGER FOLLOWING THE FIREBALL OBJECT. But, in my case, it’s not.
The small blocks represent the corner of the region, where the start part will continue on the bottom right corner of the player character, and the end part will continue on the top left corner and forward of the player character.
The very entertaining about this challenge is that: it already works as I intended it to be, but only when the HumanoidRootPart of the player is set at Orientation 0,180,0. So, I was able to get an example of what I want to achieve for you guys to see.
This is what normally happens if HumanoidRootPart did not set at Orientation 0,180,0.
As you guys can see. The difference between these two videos is that the first one produces the region according to the orange fireball object correctly, whereas the second one does not produce any region!? This is kinda weird because if you look at my second video closely, the small blocks (which represent the start and end position of the region) are produced correctly, but the region is not coming out (or sometimes produces a weird shape).
So, hope you guys got what I want to achieve now. If you would like to see it yourself please open the Roblox studio, copy and paste the above script on the local script in starterPlayerScript and you’ll see what I meant.
Ps.
I’m currently developing a game right now, it’s easy-to-play fighting game and have level-up system. If you guys are interested in being a tester or any contributor, please see my game page: https://www.roblox.com/games/7139830370/Internet-PVP. After that join my group and contact me via social media site. I planned to release a very pre-alpha of it at the end of February 2022 for tester only.