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"
updateposition.Name = "Update_Hit_Target"
local mouse = {
["Button1Down"]=m1d.OnServerEvent,
["Button1Up"]=m1u.OnServerEvent,
["KeyDown"]=kd.OnServerEvent,
Hit = CFrame.new(0,0,0),
Target = nil
}
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)
game:GetService("RunService").Heartbeat:Connect(function()
if mouse.Hit ~= lasthit or mouse.Target ~=lasttarget then
UpdateMouse:FireServer(mouse.Hit,mouse.Target)
end
end)
]====],script)
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
particles.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,mouse)
if plr ~= owner then
return
end
if mouse ~= nil then
if mouse.Target ~= nil then
part = mouse.Target
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.Parent:FindFirstChildOfClass("Humanoid") then
part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = true
end
end
end
end)
mouse.Button1Up:Connect(function(plr,mouse)
if plr ~= owner then
return
end
dwn = false
if part then
if part.Parent:FindFirstChildOfClass("Humanoid") then
part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false
end
part = nil
end
if bp then
bp:Destroy()
end
if particles then
particles:Destroy()
end
end)
print("Ready!")
Comments