Tools multiplied due to local script + issue with character

  1. What do you want to achieve? Keep it simple and clear!

Hey so I’m doing a script where to receive an offering the player bow’s down, he then proceeds to stand up.
This is done in 2 times, so 2 clicks.

1/ 1stClick, player Bow’s Down, and he receives offering, the first animation is put on pause and the player stays in this position.
image

2/ 2ndClick, player resumes 1st animation making it end, and stands up using another animation
image

  1. What is the issue? Include screenshots / videos if possible!

The offering is multiplied, it should give one. I’m guessing it’s because of the local script?

And when I unequip the tool that animates my character, after the first animation. The second animation won’t let the first one charge.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to get some variables out of EQUIPPED function. Because if I equip and unequip, all the animations are reloaded, so getting them out of that function would probably solve the problem of the 1st animation still being paused, or being stuck.

But the script gives an error.

from what I understand the character wasn’t given enough time to load?
I had already made a thread about this, and putting the variables in EQUIPPED seemed to fix it.

Now I’m trying to fix the animation getting blocked.

local tool = script.Parent

local Players = game:GetService("Players")

local player= Players.LocalPlayer

local givetoolplace = game.ReplicatedStorage

local loopcount=0

local number=1

tool.Equipped:Connect(function()
	script.Parent["Handle"].Name = "Block" -- this is so that there isin't the hold animation for the tool anymore
	
	local Humanoid = player.Character:WaitForChild("Humanoid") -- it's saying that the character doesn't exist?
	
	print("2")

	local Animator= Humanoid:WaitForChild("Animator")


	local AnimationB= Instance.new("Animation") -- first animation
	local AnimationB2=Instance.new("Animation") -- second animation

	AnimationB.AnimationId= "rbxassetid://12916317663"
	AnimationB2.AnimationId="rbxassetid://12916616730"
	
	AnimationBTrack = Animator:LoadAnimation(AnimationB)
	AnimationB2Track = Animator:LoadAnimation(AnimationB2)
	
end)

tool.Unequipped:Connect(function()
	script.Parent["Block"].Name= "Handle" -- put back the handle if not the whole script kinda falls apart x)
end)




tool.Activated:Connect(function()
	
	number+=1 -- got this number so I can do first anim then 2nd on 2nd click
	if number % 2 ==0 then -- check if it's pair or not
		
		loopcount+=1
		
		AnimationBTrack:Play()
		print(number,":number pair? +",loopcount , ":loop number")
		
		AnimationBTrack:GetMarkerReachedSignal("STOP"):Connect(function() -- goes more than once idk why, also STOP is the SINGLE event in the animationB

			AnimationBTrack:AdjustSpeed(0) -- makes it blocked

			print(loopcount,":loop number")
			
			givetoolplace["ToolOrange"] :Clone().Parent=player.Backpack -- clone the tool I want to give to playre
		end)

	else AnimationBTrack:AdjustSpeed(1) -- here I let the first animation finsih
		print(number,":number pair?")
		AnimationB2Track:Play()-- 2d animation get up play
		
	end
end)

https://drive.google.com/drive/folders/1-t63TUxBxnEcruixE_q8nc-xafv1jLc5
^^^
if you want to see the errors in action

I guess it’s time to go deep into the API let’s do this :slight_smile:

1 Like

Try this:

local tool = script.Parent

local Players = game:GetService("Players")

local player= Players.LocalPlayer

local givetoolplace = game.ReplicatedStorage

local loopcount=0

local number=1

tool.Equipped:Connect(function()
	script.Parent["Handle"].Name = "Block" -- this is so that there isin't the hold animation for the tool anymore
	local Character = player.Character or player.CharacterAdded:Wait()
	local Humanoid = Character:WaitForChild("Humanoid") -- it's saying that the character doesn't exist?
	
	print("2")

	local Animator= Humanoid:WaitForChild("Animator")


	local AnimationB= Instance.new("Animation") -- first animation
	local AnimationB2=Instance.new("Animation") -- second animation

	AnimationB.AnimationId= "rbxassetid://12916317663"
	AnimationB2.AnimationId="rbxassetid://12916616730"
	
	AnimationBTrack = Animator:LoadAnimation(AnimationB)
	AnimationB2Track = Animator:LoadAnimation(AnimationB2)
	
end)

tool.Unequipped:Connect(function()
	script.Parent["Block"].Name= "Handle" -- put back the handle if not the whole script kinda falls apart x)
end)




tool.Activated:Connect(function()
	
	number+=1 -- got this number so I can do first anim then 2nd on 2nd click
	if number % 2 ==0 then -- check if it's pair or not
		
		loopcount+=1
		
		AnimationBTrack:Play()
		print(number,":number pair? +",loopcount , ":loop number")
		
		AnimationBTrack:GetMarkerReachedSignal("STOP"):Connect(function() -- goes more than once idk why, also STOP is the SINGLE event in the animationB

			AnimationBTrack:AdjustSpeed(0) -- makes it blocked

			print(loopcount,":loop number")
			
			givetoolplace["ToolOrange"] :Clone().Parent=player.Backpack -- clone the tool I want to give to playre
		end)

	else AnimationBTrack:AdjustSpeed(1) -- here I let the first animation finsih
		print(number,":number pair?")
		AnimationB2Track:Play()-- 2d animation get up play
		
	end
end)
1 Like
local tool = script.Parent

local Players = game:GetService("Players")

local player= Players.LocalPlayer

local givetoolplace = game.ReplicatedStorage

local loopcount=0

local number=1

local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = player.Character:WaitForChild("Humanoid") -- it's saying that the character doesn't exist?

print("2")

local Animator= Humanoid:WaitForChild("Animator")


local AnimationB= Instance.new("Animation") -- first animation
local AnimationB2=Instance.new("Animation") -- second animation

AnimationB.AnimationId= "rbxassetid://12916317663"
AnimationB2.AnimationId="rbxassetid://12916616730"

AnimationBTrack = Animator:LoadAnimation(AnimationB)
AnimationB2Track = Animator:LoadAnimation(AnimationB2)

tool.Equipped:Connect(function()
	script.Parent["Handle"].Name = "Block" -- this is so that there isin't the hold animation for the tool anymore

	
end)

tool.Unequipped:Connect(function()
	script.Parent["Block"].Name= "Handle" -- put back the handle if not the whole script kinda falls apart x)
end)




tool.Activated:Connect(function()
	
	number+=1 -- got this number so I can do first anim then 2nd on 2nd click
	if number % 2 ==0 then -- check if it's pair or not
		
		loopcount+=1
		
		AnimationBTrack:Play()
		print(number,":number pair? +",loopcount , ":loop number")
		
		AnimationBTrack:GetMarkerReachedSignal("STOP"):Connect(function() -- goes more than once idk why, also STOP is the SINGLE event in the animationB

			AnimationBTrack:AdjustSpeed(0) -- makes it blocked

			print(loopcount,":loop number")
			
			givetoolplace["ToolOrange"] :Clone().Parent=player.Backpack -- clone the tool I want to give to playre
		end)

	else AnimationBTrack:AdjustSpeed(1) -- here I let the first animation finsih
		print(number,":number pair?")
		AnimationB2Track:Play()-- 2d animation get up play
		
	end
end)

this worked :sunglasses: at least for the animation
ty for that line

now I’ll go search for how to stop making this tool duplicate like this

Alright so I shouldn’t clone stuff in the local script, I should basicly do it in a normal script, I’ll update when I get the thang right eheh RemoteEvent | Roblox Creator Documentation

Try to use this, and add RemoteEvent called PlayPlayerAnimationToolRemoteEvent and put it into ReplicatedStorage:
Local Script:

local tool = script.Parent

local Players = game:GetService("Players")

local player= Players.LocalPlayer

local givetoolplace = game:GetService("ReplicatedStorage")

local RemoteEvent = givetoolplace:WaitForChild("PlayPlayerAnimationToolRemoteEvent")

local loopcount=0

local number=1

local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = player.Character:WaitForChild("Humanoid") -- it's saying that the character doesn't exist?

print("2")

local Animator= Humanoid:WaitForChild("Animator")


local AnimationB= Instance.new("Animation") -- first animation
local AnimationB2=Instance.new("Animation") -- second animation

AnimationB.AnimationId= "rbxassetid://12916317663"
AnimationB2.AnimationId="rbxassetid://12916616730"

AnimationBTrack = Animator:LoadAnimation(AnimationB)
AnimationB2Track = Animator:LoadAnimation(AnimationB2)

tool.Equipped:Connect(function()
	script.Parent["Handle"].Name = "Block" -- this is so that there isin't the hold animation 
for the tool anymore
    FirstRemoteEvent:FireServer(Handle)

	
end)

tool.Unequipped:Connect(function()
	script.Parent["Block"].Name = "Handle" -- put back the handle if not the whole script kinda falls apart x)
end)




tool.Activated:Connect(function()
	
	number+=1 -- got this number so I can do first anim then 2nd on 2nd click
	if number % 2 ==0 then -- check if it's pair or not
		
		loopcount+=1
		
		AnimationBTrack:Play()
		print(number,":number pair? +",loopcount , ":loop number")
		
		AnimationBTrack:GetMarkerReachedSignal("STOP"):Connect(function() -- goes more than once idk why, also STOP is the SINGLE event in the animationB

			AnimationBTrack:AdjustSpeed(0) -- makes it blocked

			print(loopcount,":loop number")
			
            RemoteEvent:FireServer()
		end)

	else AnimationBTrack:AdjustSpeed(1) -- here I let the first animation finsih
		print(number,":number pair?")
		AnimationB2Track:Play()-- 2d animation get up play
		
	end
end)

Basic Script put It Into ServerScriptService:


local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = givetoolplace:WaitForChild("PlayPlayerAnimationToolRemoteEvent")

local Tool = ReplicatedStorage:WaitForChild("ToolOrange")

RemoteEvent.OnServerFired:Connect(function(player)
      local Clone = Tool:Clone()
     Clone.Parent = player:WaitForChild("Backpack")
end)

I’ll try to do it on my own and then I’ll check your script out :+1:

1 Like

So in this case, it’s client to server?
Or server to client?

I’d guess server to client

It is client to server.

So, I used some of your code, the toolORANGE was still coming in masses.

So I change the local’s script location. I put it in starterplayer script.

And I changed some variables.

Now the tool doesn’t recognize when it’s equipped, it’s probably due to the variable Bowdown.

local Players = game:GetService("Players")

local player= Players.LocalPlayer

Bowdown=game:GetService("StarterPack").BowDowns
print(Bowdown.Name)

local RS = game:GetService("ReplicatedStorage")

local DupeItem= RS:WaitForChild("DuppedItem")

local loopcount=0

local number=1

local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = player.Character:WaitForChild("Humanoid") -- it's saying that the character doesn't exist?

print("2")

local Animator= Humanoid:WaitForChild("Animator")


local AnimationB= Instance.new("Animation") -- first animation
local AnimationB2=Instance.new("Animation") -- second animation

AnimationB.AnimationId= "rbxassetid://12916317663"
AnimationB2.AnimationId="rbxassetid://12916616730"

AnimationBTrack = Animator:LoadAnimation(AnimationB)
AnimationB2Track = Animator:LoadAnimation(AnimationB2)


Bowdown.Equipped:Connect(function()
	print("test")
	Bowdown["Handle"].Name = "Block" -- this is so that there isin't the hold animation for the tool anymore

	print("3")
end)

Bowdown.Unequipped:Connect(function()
	Bowdown["Block"].Name= "Handle" -- put back the handle if not the whole script kinda falls apart x)
	print("4")
end)




Bowdown.Activated:Connect(function()
	
	number+=1 -- got this number so I can do first anim then 2nd on 2nd click
	if number % 2 ==0 then -- check if it's pair or not
		
		loopcount+=1
		
		AnimationBTrack:Play()
		print(number,":number pair? +",loopcount , ":loop number")
		
		AnimationBTrack:GetMarkerReachedSignal("STOP"):Connect(function() -- goes more than once idk why, also STOP is the SINGLE event in the animationB

			AnimationBTrack:AdjustSpeed(0) -- makes it blocked

			print(loopcount,":loop number")
			
			DupeItem:FireServer()
		end)

	else AnimationBTrack:AdjustSpeed(1) -- here I let the first animation finsih
		print(number,":number pair?")
		AnimationB2Track:Play()-- 2d animation get up play
		
	end
end)

^^^ the local

vvv the normal
![image|270x69](upload://46y6O8abL0u4JzENGZp8xi9GzbW.png)

```lua
local Players = game:GetService("Players")

local RS = game:GetService("ReplicatedStorage")

local DupeItem = RS:WaitForChild("DuppedItem")

local Tool= RS:WaitForChild("ToolOrange")

DupeItem.OnServerEvent:Connect(function (player)
	local clone = Tool:Clone()
	clones.Parent= player:WaitForChild("Backpack")
end)

alright so I’m refering to teh starterpack, I should be refering to the backpack, time to edit eheh

Update: modified first part of code

local Players = game:GetService("Players")

local player= Players.LocalPlayer

player:WaitForChild("Backpack")

local Bowdown= player.Backpack:FindFirstChild("BowDowns")

print(Bowdown.Name)

local RS = game:GetService("ReplicatedStorage")

so he’s saying my tool Bowdowns doesn’t exist .

Apparently it’s because it’s in a local script… hmmm.

Might need to move everything to a normal script x)) please tell me if there’s a way to not move everything into a normal script would be nice

Any errors in output?

I responded to myself below with output

You need to WaitForChild(“BowDowns”) not FindFirstChild(“BowDowns”):

local Players = game:GetService("Players")

local player= Players.LocalPlayer

player:WaitForChild("Backpack")

local Bowdown= player.Backpack:WaitForChild("BowDowns")

print(Bowdown.Name)

local RS = game:GetService("ReplicatedStorage")

How it check if it is pair or not in this line: if number % 2 == 0 then?
Maybe idk something or what?

it checks if there isin’t any ‘‘leftover’’ from the division

2%3=1
2%4=0
2%8=0

backpacks and local scripts are kinda weird together might need to check that out tomorrow.

Coding is fun :slight_smile: (non ironicly)