-
What do you want to achieve? Keep it simple and clear!
I want to make a script where when a player presses V, rings (already-made) show up on their hands. And then when you hold down v on a player, an animation plays and is supposed to do damage to them. Then after that, an explosion will finish them off.
-
What is the issue? Include screenshots / videos if possible!
The issue is that when I try to make the rings go on their hands, it doesn’t work and the animation doesn’t play. Before I incorporated the rings, the animation played fine.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked for solutions on the developer hub. I have tried to put the rings in different locations but it doesn’t work.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Run = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local Mouse = player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local vHeld = UserInputService:IsKeyDown(Enum.KeyCode.V)
Run.RenderStepped:Connect(function()
local Target = Mouse.Target
if Target and Target:FindFirstAncestorOfClass("Model") then
local model = Target:FindFirstAncestorOfClass("Model")
if model:FindFirstChild("Humanoid") then
local V = Enum.KeyCode.V
local function isVKeyDown()
return UserInputService:IsKeyDown(V)
end
local function input(_input, _gameProcessedEvent)
if isVKeyDown() and model:FindFirstChild("Humanoid") then
print("The player pressed V! A humanoid was found!")
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local CanPlay = true
local CoolDown = 3
if CanPlay == true then
CanPlay = false
if player.Character:FindFirstChild("Rings") == false then
local ringsclone = game.ReplicatedStorage:WaitForChild("Rings"):Clone()
ringsclone.Parent = player.Character
local animation = Instance.new("Animation")
animation.Parent = humanoid
animation.AnimationId = "rbxassetid://12176124193"
local anim = humanoid:LoadAnimation(animation)
anim:Play()
game.ReplicatedStorage.Fight:FireServer(model:FindFirstChild("Humanoid"))
wait(CoolDown + anim.Length)
CanPlay = true
elseif player.Character:FindFirstChild("Rings") then
local animation = Instance.new("Animation")
animation.Parent = humanoid
animation.AnimationId = "rbxassetid://12176124193"
local anim = humanoid:LoadAnimation(animation)
anim:Play()
game.ReplicatedStorage.Fight:FireServer(model:FindFirstChild("Humanoid"))
wait(CoolDown + anim.Length)
CanPlay = true
end
end
elseif isVKeyDown() and player.Character:FindFirstChild("Rings") == false then
local ringsclone = game.ReplicatedStorage:WaitForChild("Rings"):Clone()
ringsclone.Parent = player.Character
print("The player pressed V but a humanoid wasn't found.")
elseif model:FindFirstChild("Humanoid") and not isVKeyDown() then
print("A humanoid was found but the player didn't press V.")
end
end
UserInputService.InputBegan:Connect(input)
end
end
end)