Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local cam = workspace.CurrentCamera
- local mouse = player:GetMouse()
- local us = game:GetService("UserInputService")
- local oldpart = nil
- local currentpart = nil
- local currentcf = nil
- local strength = 1
- local vel = Vector3.new(0,0,0)
- local lastpos = Vector3.new(0,0,0)
- local remote = player:WaitForChild("Yet")
- player.Chatted:Connect(function(msg)
- if string.sub(string.lower(msg),1,10) == ";strength " then
- local num = tonumber(string.sub(msg,11))
- if num ~= nil then
- strength = num
- end
- end
- end)
- function subtractcf(a, b)
- local x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33 = a:components()
- return CFrame.new(x - b.x, y - b.y, z - b.z, m11, m12, m13, m21, m22, m23, m31, m32, m33);
- end
- local function multiplyCFrame(a, b)
- local ax, ay, az, a11, a12, a13, a21, a22, a23, a31, a32, a33 = a:components()
- local bx, by, bz, b11, b12, b13, b21, b22, b23, b31, b32, b33 = b:components()
- local x = ax*bx
- local y = ay*by
- local z = az*bz
- local m11 = a11*b11
- local m12 = a12*b12
- local m13 = a13*b13
- local m21 = a21*b21
- local m22 = a22*b22
- local m23 = a23*b23
- local m31 = a31*b31
- local m32 = a32*b32
- local m33 = a33*b33
- return CFrame.new(x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33)
- end
- function valid(part)
- if part.Anchored == false then
- return true
- else
- return false
- end
- end
- us.InputBegan:Connect(function(inp)
- if inp.UserInputType == Enum.UserInputType.MouseButton1 then
- local target = mouse.Target
- if valid(target) then
- lastpos = target.Position
- currentcf = cam.CFrame:toObjectSpace(target.CFrame)
- currentpart = target
- remote:FireServer("anchor",currentpart)
- end
- end
- end)
- us.InputEnded:Connect(function(inp)
- if inp.UserInputType == Enum.UserInputType.MouseButton1 then
- --currentpart.Velocity = Vector3.new(vel.X*20,vel.Y*20,vel.Z*20)
- remote:FireServer("unanchor",currentpart,Vector3.new((vel.X*20)*strength,(vel.Y*20)*strength,(vel.Z*20)*strength))
- vel = Vector3.new(0,0,0)
- currentpart = nil
- currentcf = nil
- end
- end)
- mouse.KeyUp:Connect(function(key)
- if key:lower() == "e" then
- remote:FireServer("spawnpart")
- end
- end)
- --
- game:GetService("RunService").RenderStepped:Connect(function()
- if currentpart ~= nil and currentcf ~= nil then
- currentpart.CFrame = cam.CFrame * currentcf
- remote:FireServer("update",currentpart,currentpart.CFrame)
- vel = Vector3.new(currentpart.Position.X-lastpos.X,currentpart.Position.Y-lastpos.Y,currentpart.Position.Z-lastpos.Z)
- lastpos = currentpart.Position
- end
- local targ = mouse.Target
- if targ ~= nil and targ.Anchored == false then
- if targ ~= oldpart and valid(targ) then
- if oldpart ~= nil then
- oldpart.Selec:Destroy()
- end
- local selec = Instance.new("SelectionBox",targ)
- selec.Name = "Selec"
- selec.Adornee = targ
- selec.Color3 = Color3.new(0,0,0)
- selec.LineThickness = 0.025
- oldpart = targ
- elseif targ ~= oldpart and not valid(targ) then
- if oldpart ~= nil then
- oldpart.Selec:Destroy()
- oldpart = nil
- end
- end
- else
- if oldpart ~= nil then
- oldpart.Selec:Destroy()
- oldpart = nil
- end
- end
- end)
Add Comment
Please, Sign In to add comment