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

It is supposed to do the action when you press T + click on the target player but isn't working?

Asked by 3 years ago
Edited 3 years ago

The script is like a magic move that you can use on others and I want to be able to press T then click on the target and work and this is the script I am currently using:

local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")


local anim = Instance.new("Animation")
anim.AnimationId = "https://www.roblox.com/asset/?id='5480157154'


mouse.KeyDown:connect(function(key)
      if key == "t" then
   local playAnim = humanoid:LoadAnimation(anim)
   playAnim:Play()

    end
end)

If you know please do answer below as I am eager to find out. the solution.

0
use userinputservice zadobyte 692 — 3y
0
dont use keydown , use UserInputService, you literally required it xXKatchaXx 0 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Next time, please use UserInputService as KeyDown is deprecated, however upon reading your script I have seen that you made a mistake about the animation Id.

Please replace:

anim.AnimationId = "https://www.roblox.com/asset/?id='5480157154'

To:

anim.AnimationId = "https://www.roblox.com/asset/?id=5480157154"

Make sure that you own the animation otherwise it won't work. Roblox doesn't allow animation-sharing to others.

Try changing the parent of your animation inside the script:

anim.Parent = script
0
Changing the parent of the anim will not do anything. Cynical_Innovation 595 — 3y
Ad
Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago

Might be the way you're detecting the keydown. Also, use rbxassetid instead of the way you did it.

local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")


local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://5480157154'


UIS.InputBegan:Connect(function(input, process)
    if not process then
        if input.KeyCode == Enum.KeyCode.T then
            local playAnim = humanoid:LoadAnimation(anim)
            playAnim:Play()
        end
    end
end)

Cheers, Zander

Answer this question