Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --script (server side script)
- wait(3)
- local Player = game:GetService("Players").plytalent--<=== Replace With Your Name
- local Mouse,mouse,UserInputService,ContextActionService
- do
- script.Parent = Player.Character
- local CAS = {Actions={}}
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event(loaded)"
- Event.Parent = Player.Character
- local fakeEvent = function()
- local t = {_fakeEvent=true}
- t.Connect = function(self,f)self.Function=f end
- t.connect = t.Connect
- return t
- end
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- function CAS:BindAction(name,fun,touch,...)
- CAS.Actions[name] = {Name=name,Function=fun,Keys={...}}
- end
- function CAS:UnbindAction(name)
- CAS.Actions[name] = nil
- end
- local function te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent and t.Function then
- t.Function(...)
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=Player then return end
- if io.isMouse then
- m.Target = io.Target
- m.Hit = io.Hit
- elseif io.UserInputType == Enum.UserInputType.MouseButton1 then
- if io.UserInputState == Enum.UserInputState.Begin then
- m:TrigEvent("Button1Down")
- else
- m:TrigEvent("Button1Up")
- end
- else
- for n,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- if io.UserInputState == Enum.UserInputState.Begin then
- m:TrigEvent("KeyDown",io.KeyCode.Name:lower())
- UIS:TrigEvent("InputBegan",io,false)
- else
- m:TrigEvent("KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent("InputEnded",io,false)
- end
- end
- end)
- Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
- end
- hitboxdamagepart = Instance.new("Part",Player.Character)
- hitboxdamageweld = Instance.new("Weld",hitboxdamagepart)
- hitboxdamagepart.Transparency = 0.5
- hitboxdamagepart.Size = Vector3.new(5,5,0)
- hitboxdamagepart.Anchored = false
- hitboxdamagepart.CanCollide = false
- hitboxdamageweld.Part0 = Player.Character.Torso
- hitboxdamageweld.Part1 = hitboxdamagepart
- hitboxdamageweld.C0 = CFrame.new(0,0,-1)
- attack = false
- mouse.KeyDown:Connect(function(k)
- if k then
- print(k)
- end
- if k == "q" then
- attack = true
- hitboxdamagepart.Transparency = 0
- end
- end)
- mouse.KeyUp:Connect(function(k)
- if k == "q" then
- attack = false
- hitboxdamagepart.Transparency = 0.5
- end
- end)
- while wait(0.5) do
- if attack then
- hitboxdamagepart.Touched:Connect(function(hit)
- if hit.Parent.Name ~= Player.Name then
- print(hit.Parent.Name.." "..hit.Name)
- humhit = hit.Parent:FindFirstChildOfClass("Humanoid")
- if humhit.Health > 0 then
- humhit.Health = humhit.Health - 1
- end
- end
- end)
- end
- end
- --local script (client side script)
- local Player = game:GetService("Players").LocalPlayer
- local Char = Player.Character
- local Event = Char:WaitForChild("UserInput_Event(loaded)")
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a then return end
- local io = {KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState}
- Event:FireServer(io)
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local Changed = false
- local Mouse = Player:GetMouse()
- local h,t = Mouse.Hit,Mouse.Target
- while wait(1/30) do
- if h~=Mouse.Hit or t~=Mouse.Target then
- Event:FireServer({isMouse=true,Target=Mouse.Target,Hit=Mouse.Hit})
- h,t=Mouse.Hit,Mouse.Target
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement