What I am essentially trying to do is make a Bezier Curve from the player to a brick and instead of it plotting, it's just all spawning the bricks in the middle of the baseplate. Any help is greatly appreciated. This game has FilteringEnabled
set to true.
ClientScript - LocalScript
:
--// Variables local Player = game.Players.LocalPlayer local Camera = game.Workspace.CurrentCamera local Mouse = Player:GetMouse() --// Events and Modules local GameStuff = game.ReplicatedStorage.GameStuff local CreateShot = GameStuff.Events.CreateShot local Shoot = GameStuff.Events.Shoot --// Setup Mouse.Button1Down:Connect(function() Shoot:FireServer(Player.Character.Torso, Mouse.Target) end)
ServerScript - Script
:
--// Events and Modules local GameStuff = game.ReplicatedStorage.GameStuff local CreateShot = GameStuff.Events.CreateShot local Shoot = GameStuff.Events.Shoot local ShotHandler = require(GameStuff.Modules.ShotHandler) function createPoints(start, negative) local part1 = Instance.new("Part") if negative == false then part1.CFrame = start.CFrame * CFrame.new(3, 2, 0) else part1.CFrame = start.CFrame * CFrame.new(-3, -2, 0) end return part1 end Shoot.OnServerEvent:Connect(function(player, startpoint, endpoint) print (startpoint.Name .. " " .. endpoint.Name) print (tostring(startpoint.CFrame) .. " -------------- " .. tostring(endpoint.CFrame)) ShotHandler.Shoot(startpoint, createPoints(startpoint, false), createPoints(endpoint, true), endpoint) end)
ShotHandler - ModuleScript
:
function addSegment(positon) local seg = Instance.new("Part", game.Workspace.ShotHolder) seg.Size = Vector3.new(1,1,1) seg.BrickColor = BrickColor.new("Medium stone grey") seg.Anchored = true seg.CanCollide = false end function equation(t, a, b, c, d) return ( (((1 - t)^3)*a) + (3*((1 - t)^2)*t*b) + (3*(1 - t)*(t^2)*c) + ((t^3)*d) ) end function drawBezier(a, b, c, d) local mag = 0 local lastPos = equation(0, a, b, c, d) for t = 0, 1, .001 do local curPos = equation(t, a, b, c, d) mag = mag + (lastPos - curPos).magnitude if( mag > 1 )then mag = 0 addSegment(curPos) end lastPos = curPos end end local shot = {} function shot.Shoot(point1, point2, point3, point4) game.Workspace.ShotHolder:ClearAllChildren() wait(.1) drawBezier(point1.Position, point2.Position, point3.Position, point4.Position) end return shot