Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script.Parent = owner.PlayerGui
- local part = nil
- local dwn = false
- local mouse_fd = Instance.new("Folder",script)
- mouse_fd.Name = "Mouse"
- local m1d,m1u,kd,updateposition = Instance.new("RemoteEvent",mouse_fd), Instance.new("RemoteEvent",mouse_fd), Instance.new("RemoteEvent",mouse_fd), Instance.new("RemoteEvent",mouse_fd)
- m1d.Name = "Button1Down"
- m1u.Name = "Button1Up"
- kd.Name = "KeyDown"
- local oldownership = nil
- updateposition.Name = "Update_Hit_Target"
- local mouse = {
- ["Button1Down"]=m1d.OnServerEvent,
- ["Button1Up"]=m1u.OnServerEvent,
- ["KeyDown"]=kd.OnServerEvent,
- Hit = CFrame.new(0,0,0),
- Target = nil
- }
- updateposition.OnServerEvent:Connect(function(plr,hit,target)
- if plr ~= owner then
- return
- end
- mouse.hit = hit
- mouse.Hit = hit
- mouse.target = target
- mouse.Target = target
- end)
- mouse.KeyDown:Connect(function(plr,k)
- if plr ~= owner then
- return
- end
- if k == "t" and part ~= nil then
- local clone = part:Clone()
- clone.Parent = workspace
- clone.Anchored = false
- clone:ClearAllChildren()
- clone.CanCollide = true
- bp.Parent = clone
- if part.Parent:FindFirstChildOfClass("Humanoid") then
- part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false
- end
- part:Destroy()
- part = clone
- end
- end)
- mouse.Button1Down:Connect(function(plr)
- if plr ~= owner then
- return
- end
- if mouse ~= nil then
- if mouse.Target ~= nil then
- part = mouse.Target
- oldownership = part:GetNetworkOwner()
- bp = Instance.new("BodyPosition",part)
- bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- bp.Position = part.Position
- dwn = true
- end
- end
- while dwn do
- game:GetService("RunService").Stepped:Wait()
- bp.Position = mouse.Hit.p
- if part then
- if part:GetNetworkOwner() ~= owner and not part.Anchored and part:IsDescendantOf(workspace) then
- part:SetNetworkOwner(owner)
- end
- if part.Parent:FindFirstChildOfClass("Humanoid") then
- part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = true
- end
- end
- end
- end)
- mouse.Button1Up:Connect(function(plr)
- if plr ~= owner then
- return
- end
- dwn = false
- if part then
- if part.Parent:FindFirstChildOfClass("Humanoid") then
- part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false
- end
- if part:GetNetworkOwner() ~= oldownership then
- part:SetNetworkOwner(oldownership)
- end
- part = nil
- end
- if bp then
- bp:Destroy()
- end
- end)
- NLS([====[
- local UpdateMouse = script.Parent.Mouse.Update_Hit_Target
- local M1Down = script.Parent.Mouse.Button1Down
- local M1Up = script.Parent.Mouse.Button1Up
- local KDown = script.Parent.Mouse.KeyDown
- local mouse = owner:GetMouse()
- local lasthit,lasttarget = mouse.Hit,mouse.Target
- mouse.KeyDown:Connect(function(k)
- KDown:FireServer(k)
- end)
- mouse.Button1Down:Connect(function()
- M1Down:FireServer()
- end)
- mouse.Button1Up:Connect(function()
- M1Up:FireServer()
- end)
- game:GetService("RunService").Heartbeat:Connect(function()
- if mouse.Hit ~= lasthit or mouse.Target ~=lasttarget then
- UpdateMouse:FireServer(mouse.Hit,mouse.Target)
- end
- end)
- ]====],script)
- print("Ready!")
Add Comment
Please, Sign In to add comment