Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I am in need of help with Mouse range, for keybind?

Asked by 3 years ago
Edited 3 years ago

Hi! I'm in need of making an edit to my script that allows the player to kill another character with just the click of a button? I want to give this ability some range, I don't just want the player to be able to kill the other character from the other side of the map. If you are in need of seeing the script, here it is.

`local Debounce = false

script.Parent.Kill.OnServerEvent:Connect(function(Player, Mouse)
if Mouse.Parent:FindFirstChild("Humanoid") then
        local Animation = script.Parent.Pain
        local LoadedAnim = Mouse.Parent.Humanoid:LoadAnimation(Animation)
        local Anim = script.Parent.User
        local User = script.Parent.Parent.Humanoid:LoadAnimation(Anim)
        if Debounce == false then
            Debounce = true
            LoadedAnim:Play()
            Mouse.Parent.Humanoid:TakeDamage(50)
            User:Play()
            wait(5)
            LoadedAnim:Stop()
            User:Stop()
        else
            Debounce = false
            print("Nawr")
        end
    end
 end)

` It is a server-script binded by a Remote Event.

Answer this question