Error with when on click change union csg?
Asked by
3 years ago Edited 3 years ago
My error code is csg -21.
my code;
client localscript:
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
04 | local createpart = game.ReplicatedStorage.createpart |
06 | local debris = game:GetService( "Debris" ) |
08 | mouse.Button 1 Down:Connect( function () |
09 | local Unitray = mouse.UnitRay |
10 | local beam = Instance.new( "Part" ,workspace) |
11 | local x = tonumber (mouse.Hit.X + "0" ) |
12 | local y = tonumber (mouse.Hit.Y + "0" ) |
13 | local z = tonumber (mouse.Hit.Z + "0" ) |
14 | beam.BrickColor = BrickColor.new( "Toothpaste" ) |
15 | beam.FormFactor = "Custom" |
16 | beam.Material = "Neon" |
17 | beam.Transparency = 0.6 |
20 | beam.CanCollide = false |
21 | local distance = (mouse.Origin.p - mouse.Hit.p).magnitude |
22 | beam.Size = Vector 3. new( 0.2 , 0.2 ,distance) |
23 | beam.CFrame = CFrame.new(mouse.Origin.p, mouse.Hit.p) * CFrame.new( 0 , 0 , -distance / 2 ) |
24 | createpart:FireServer(Vector 3. new(math.floor(x+. 5 ),math.floor(y+. 5 ),math.floor(z+. 5 )), math.random( 2 , 10 )) |
25 | debris:AddItem(beam, 2 ) |
csg handler:
01 | local destructable = workspace.Destructable |
04 | local function getcheckingparts() |
05 | for i,taba in pairs (tabl) do |
08 | for i,v in pairs (workspace:GetChildren()) do |
09 | if v.Name = = "checking" then |
17 | if workspace:FindFirstChild( "checking" ) then |
18 | local success, error , unionpart = pcall ( function () |
19 | return destructable:SubtractAsync(tabl) |
22 | if success and unionpart then |
24 | unionpart.Position = destructable.Position |
25 | unionpart.Anchored = true |
26 | unionpart.Parent = game.Workspace |
27 | destructable:Destroy() |
28 | for i,v in pairs (tabl) do |
31 | print ( "sucessfully did it" ) |
create part:
01 | local createpart = game.ReplicatedStorage.createpart |
03 | local debris = game:GetService( "Debris" ) |
05 | createpart.OnServerEvent:Connect( function (client,position,number) |
08 | local hitthingy = Instance.new( "Part" ,workspace) |
09 | hitthingy.Name = "checking" |
10 | hitthingy.Anchored = true |
11 | hitthingy.CanCollide = false |
12 | hitthingy.Size = Vector 3. new( 5 , 5 , 5 ) |
13 | hitthingy.Orientation = Vector 3. new(math.random(- 180 , 180 ),math.random(- 180 , 180 ),math.random(- 180 , 180 )) |
15 | hitthingy.Position = position |
16 | debris:AddItem(hitthingy, 2 ) |
heres where i put my scripts;
https://ibb.co/6sC67ZZ
sorry it isnt clean. this is my first post. that is for questioning