Well, I’m trying to get the red object to be thrown forward until it touches the green object, when that happens, the red object must stop moving immediately.
The red object is taking too long to stop moving, and I need the object to stop before crossing, because I’m trying to create a spell collision with it.
Screenshot:
Script:
local FX = workspace:WaitForChild("FX")
local rStorage = game:GetService("ReplicatedStorage")
local rEvent = rStorage.Events:WaitForChild("Projectile")
rEvent.OnServerEvent:Connect(function(plr)
local char = workspace:WaitForChild(plr.Name)
local hum = char:WaitForChild("HumanoidRootPart")
local x = Instance.new("Part", FX)
x.Name = "Projectile"
x.Anchored = false
x.CanCollide = false
x.BrickColor = BrickColor.new("Really red")
x.Material = "Neon"
x.Shape = "Ball"
x.Size = Vector3.new(3,3,3)
x.CFrame = hum.CFrame * CFrame.new(0,0,-3)
game.Debris:AddItem(x, 15)
local bv = Instance.new("BodyVelocity", x)
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Velocity = hum.CFrame.lookVector * 100
x.Touched:Connect(function(hit)
if hit.Name == "Barrier" then
bv.Velocity = Vector3.new()
end
end)
end)
Thank you for your attention!