Im new to scripting and I making a jojo pose.
i have an problem that when i press P and the script run once and its working but then every time i run the script again by pressing P after run it once it doesn’t work and its say on the output The Parent property of Effect is locked, current parent: NULL, new parent HumanoidRootPart - Client - Pose:18
Pose(local script in StarterPack)
local player = script.Parent.Parent
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local Lighting = game:GetService("Lighting")
local ClonedEffect = Lighting:WaitForChild("Effect"):Clone()
local ClonedSound = Lighting:WaitForChild("Sound"):Clone()
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local Taunt = Instance.new("Animation")
local Taunt2 = Instance.new("Animation")
Taunt.AnimationId = 'rbxassetid://6438454175'
Taunt2.AnimationId = 'rbxassetid://6435596058'
local taunted = false
Pressed = false
UIS.InputBegan:connect(function(input,gameProcessed)
if input.KeyCode == Enum.KeyCode.P and Pressed == false then
ClonedEffect.Parent = player.Character.HumanoidRootPart
ClonedSound.Parent = player.Character.HumanoidRootPart
ClonedSound:Play()
-- Load animation code\ goes here, I'm too lazy
taunted = true
char.Humanoid.WalkSpeed = 0
local LoadAnimation = char.Humanoid:LoadAnimation(Taunt)
local LoadAnimation2 = char.Humanoid:LoadAnimation(Taunt2)
local cp = math.random(1, 2)
if cp == 1 then
LoadAnimation:Play(0.1, 1, 1)
elseif cp == 2 then
LoadAnimation2:Play(0.1, 1, 1)
end
char.Humanoid.WalkSpeed = 16
taunted = false
Pressed = true
elseif input.KeyCode == Enum.KeyCode.P and Pressed == true then
ClonedEffect:Destroy()
ClonedSound:Destroy()
wait()
Pressed = false
end
end)
Hi @NoSwea_t quick question, I want to do that when you press P second time and the clonedeffect destroy then the animation pose also stop. How do i do that?
local player = script.Parent.Parent
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local Lighting = game:GetService("Lighting")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local Taunt = Instance.new("Animation")
local Taunt2 = Instance.new("Animation")
Taunt.AnimationId = 'rbxassetid://6438454175'
Taunt2.AnimationId = 'rbxassetid://6435596058'--put id here -- other animations 2262820217, 2262813409, 2425154387,
local tauntTable = {Taunt,Taunt2} -- Put any animations that you want in here
local randAnim
local animPlay
local taunted = false
Pressed = false
local ClonedEffect
local ClonedSound
UIS.InputBegan:connect(function(input,gameProcessed)
if input.KeyCode == Enum.KeyCode.P and Pressed == false then
ClonedEffect = Lighting:WaitForChild("Effect"):Clone()
ClonedSound = Lighting:WaitForChild("Sound"):Clone()
ClonedEffect.Parent = char.HumanoidRootPart
ClonedSound.Parent = char.HumanoidRootPart
ClonedSound:Play()
-- Load animation code\ goes here, I'm too lazy
taunted = true
char.Humanoid.WalkSpeed = 0
randAnim = tauntTable[math.random(1,#tauntTable)]
animPlay = char.Humanoid.Animator:LoadAnimation(randAnim)
animPlay:Play(.1,1,1)
Pressed = true
wait(5)
char.Humanoid.WalkSpeed = 16
taunted = false
elseif input.KeyCode == Enum.KeyCode.P and Pressed == true then
animPlay:Stop(.1)
ClonedEffect:Destroy()
ClonedSound:Destroy()
Pressed = false
end
end)