Jojo pose, error on the output

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)

you only cloned the effect and sound one time so its only going to work 1 time

local ClonedEffect =  Lighting:WaitForChild("Effect"):Clone()
local ClonedSound = Lighting:WaitForChild("Sound"):Clone()
ClonedEffect.Parent = player.Character.HumanoidRootPart
ClonedSound.Parent = player.Character.HumanoidRootPart
ClonedSound:Play()

ohh i see, so how do i fix it?

I would suggest taking the first two lines of code @hiperion14 sent and put it above the parenting section of said instances.

If I put that two lines in the function the cloned effect doesn’t destroyed pls help.

Try deleting the local section of both instances.

i new scripter i dont understand what are u saying me to do pls show me.

ClonedEffect =  Lighting:WaitForChild("Effect"):Clone()
ClonedSound = Lighting:WaitForChild("Sound"):Clone()
ClonedEffect.Parent = player.Character.HumanoidRootPart
ClonedSound.Parent = player.Character.HumanoidRootPart
ClonedSound:Play()

Do this.

Now its doesnt destroy the effect when i press P again

May I see the whole script again?

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 taunted = false
Pressed = false
local ClonedEffect =  Lighting:WaitForChild("Effect"):Clone()
local ClonedSound = Lighting:WaitForChild("Sound"):Clone()


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 = 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
		wait(5)
		char.Humanoid.WalkSpeed = 16
		taunted = false
		Pressed = true
	elseif input.KeyCode == Enum.KeyCode.P and Pressed == true then
		ClonedEffect:Destroy()
		ClonedSound:Destroy()
		Pressed = false
	end
end)
local player = script.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 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
        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
        Pressed = true
        wait(5)
        char.Humanoid.WalkSpeed = 16
        taunted = false
    elseif input.KeyCode == Enum.KeyCode.P and Pressed == true then
        ClonedEffect:Destroy()
        ClonedSound:Destroy()
        Pressed = false
    end
end)

This should do it.

No, its doesnt do anything its say on the out put: GetMouse is not a valid member of Backpack “Players.sagiv200421.Backpack” - Client - Pose:2

Sorry about that, replace the first line with local player = script.Parent.Parent

Its work! thanks you so much for you time :grin:

:+1: I wish you good luck on your future projects.

Thank you so much, have a great day!

1 Like

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?

P.S: You dont have to help more if you dont want.

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)

Here you go.

Thank you so much! I dont know how to thank you, you helped me so much!