Problem solved and fixed

I have problem with server script which is activated from local script by remote event. I don’t know why it’s not working.

Server Script:

local background = game.Workspace:WaitForChild("BloomBackground")
local template = game.Workspace.Bloom_Transform
local crown = template.Bloom_MW_crown
local shirt = template.Shirt
local pants = template.Pants
local wing_l = template.Wing_Left
local wing_r = template.Wing_Right
local effect = template.RightHand.Attachment.Fire
local event = game:GetService("ReplicatedStorage").AmberS1

event.OnServerEvent:Connect(function(player)
	local tool = player.Backpack:WaitForChild("Magic Finix Amber")
	local anim = tool.LocalScript:WaitForChild("Animation")
	
	tool.Handle.Attachment.Fire.Enabled = false

	local char = player.Character

	local humanoid = char:WaitForChild("Humanoid")
	
	char.HumanoidRootPart.Anchored = true
	humanoid.WalkSpeed = 0
	humanoid.JumpHeight = 0

	local clonedBackground = background:Clone()
	clonedBackground.Name = "localBackground"
	clonedBackground.Parent = game.Workspace
	clonedBackground.CFrame = char.PrimaryPart.CFrame * CFrame.new(0, 0, 2)
	clonedBackground.Rotation = char.HumanoidRootPart.Rotation

	local cloneeffect1 = effect:Clone()
	cloneeffect1.Parent = char.RightHand

	local cloneeffect2 = effect:Clone()
	cloneeffect2.Parent = char.LeftHand

	local music = clonedBackground.MagicWinx
	music.Playing = true

	local track = humanoid:LoadAnimation(anim)
	track:Play()
	wait(3)
	cloneeffect1.Enabled = true
	cloneeffect2.Enabled = true
	wait(1.5)
	cloneeffect1.Enabled = false
	cloneeffect2.Enabled = false
	local shirtID = shirt.ShirtTemplate
	char:WaitForChild("Shirt").ShirtTemplate = shirtID
	char:WaitForChild("Pants").PantsTemplate = "rbxassetid://15724231382"
	wait(2)
	local pantsID = pants.PantsTemplate
	char:WaitForChild("Pants").PantsTemplate = pantsID
	wait(3.75)
	local wing_lclone = wing_l:Clone()
	wing_lclone.Parent = char
	wing_lclone.Handle.AccessoryWeld.Part1 = char.UpperTorso

	local wing_rclone = wing_r:Clone()
	wing_rclone.Parent = char
	wing_rclone.Handle.AccessoryWeld.Part1 = char.UpperTorso
	wait(1)

	local crownclone = crown:Clone()
	crownclone.Parent =  char
	crownclone.Handle.AccessoryWeld.Part1 = char.Head
	wait(2.5)

	cloneeffect1.Enabled = true
	cloneeffect2.Enabled = true
	wait(1)
	cloneeffect1.Enabled = false
	cloneeffect2.Enabled = false
	wait(6)

	clonedBackground:Destroy()

	humanoid.WalkSpeed = 16
	humanoid.JumpHeight = 7.2		
	char.HumanoidRootPart.Anchored = false
	tool:Destroy()
end)

Local Script:

local tool = script.Parent
local event = game:GetService("ReplicatedStorage").AmberS1
local activation = true
tool.Equipped:Connect(function(player)
	local anim = Instance.new("Animation")	
	anim.Parent = tool.LocalScript
	anim.AnimationId = "rbxassetid://15723632456"
end)

local anim = script:WaitForChild("Animation")

tool.Activated:Connect(function(player)
	if activation == true then
		activation = false
		event:FireServer()
	end
end)

4 Likes

There’s no need to use :WaitForChild in server scripts, they could be causing some of the problems you’re experiencing

Edit: I’ve also noticed in the LocalScript you have:

tool.Activated:Connect(function(player)
	if activation == true then
		activation = false
		event:FireServer()
	end
end)

You’re setting activation to false but aren’t setting it to true again

1 Like

I didn’t use false on activvation because I will delete tool and I don’t want to player use it more times at once to doesn’t bug animation.

1 Like

If the tool can only be used once you can do this instead:

local tool = script.Parent
local event = game:GetService("ReplicatedStorage").AmberS1
tool.Equipped:Once(function(player)
	local anim = Instance.new("Animation")	
	anim.Parent = tool.LocalScript
	anim.AnimationId = "rbxassetid://15723632456"
end)

local anim = script:WaitForChild("Animation")

tool.Activated:Once(function(player)
	event:FireServer()
end)
1 Like

I changed it but still nothing.

local tool = script.Parent
local event = game:GetService("ReplicatedStorage").AmberS1


tool.Equipped:Connect(function(player)
	local anim = Instance.new("Animation")	
	anim.Parent = tool.LocalScript
	anim.AnimationId = "rbxassetid://15723632456"
end)

local anim = script:WaitForChild("Animation")

tool.Activated:Once(function(player)
	event:FireServer()
end)

local background = game.Workspace:WaitForChild("BloomBackground")
local template = game.Workspace.Bloom_Transform
local crown = template.Bloom_MW_crown
local shirt = template.Shirt
local pants = template.Pants
local wing_l = template.Wing_Left
local wing_r = template.Wing_Right
local effect = template.RightHand.Attachment.Fire
local event = game:GetService("ReplicatedStorage").AmberS1

event.OnServerEvent:Connect(function(player)
	local tool = player.Backpack:WaitForChild("Magic Finix Amber")
	local anim = tool.LocalScript.Animation
	
	tool.Handle.Attachment.Fire.Enabled = false

	local char = player.Character

	local humanoid = char.Humanoid
	
	char.HumanoidRootPart.Anchored = true
	humanoid.WalkSpeed = 0
	humanoid.JumpHeight = 0

	local clonedBackground = background:Clone()
	clonedBackground.Name = "localBackground"
	clonedBackground.Parent = game.Workspace
	clonedBackground.CFrame = char.PrimaryPart.CFrame * CFrame.new(0, 0, 2)
	clonedBackground.Rotation = char.HumanoidRootPart.Rotation

	local cloneeffect1 = effect:Clone()
	cloneeffect1.Parent = char.RightHand

	local cloneeffect2 = effect:Clone()
	cloneeffect2.Parent = char.LeftHand

	local music = clonedBackground.MagicWinx
	music.Playing = true

	local track = humanoid:LoadAnimation(anim)
	track:Play()
	wait(3)
	cloneeffect1.Enabled = true
	cloneeffect2.Enabled = true
	wait(1.5)
	cloneeffect1.Enabled = false
	cloneeffect2.Enabled = false
	local shirtID = shirt.ShirtTemplate
	char.Shirt.ShirtTemplate = shirtID
	char.Pants.PantsTemplate = "rbxassetid://15724231382"
	wait(2)
	local pantsID = pants.PantsTemplate
	char.Pants.PantsTemplate = pantsID
	wait(3.75)
	local wing_lclone = wing_l:Clone()
	wing_lclone.Parent = char
	wing_lclone.Handle.AccessoryWeld.Part1 = char.UpperTorso

	local wing_rclone = wing_r:Clone()
	wing_rclone.Parent = char
	wing_rclone.Handle.AccessoryWeld.Part1 = char.UpperTorso
	wait(1)

	local crownclone = crown:Clone()
	crownclone.Parent =  char
	crownclone.Handle.AccessoryWeld.Part1 = char.Head
	wait(2.5)

	cloneeffect1.Enabled = true
	cloneeffect2.Enabled = true
	wait(1)
	cloneeffect1.Enabled = false
	cloneeffect2.Enabled = false
	wait(6)

	clonedBackground:Destroy()

	humanoid.WalkSpeed = 16
	humanoid.JumpHeight = 7.2		
	char.HumanoidRootPart.Anchored = false
	tool:Destroy()
end)
1 Like

I’ll try re-writing the scripts but it will take some time so please wait

1 Like

1 Like

This is the script I wrote to replace the Tool’s LocalScript:

local event = game:GetService("ReplicatedStorage"):WaitForChild("AmberS1")

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://15723632456"
animation.Parent = script

script.Parent.Activated:Once(function()
	event:FireServer()
end)

Now I’ll start writing the new server script

Edit: @TheCookieDragonPlays here’s the server script:

local background = workspace.BloomBackground

local template = workspace.Bloom_Transform
local crown = template.Bloom_MW_crown
local shirt = template.Shirt
local pants = template.Pants
local wing_l = template.Wing_Left
local wing_r = template.Wing_Right
local effect = template.RightHand.Attachment.Fire

game:GetService("ReplicatedStorage").AmberS1.OnServerEvent:Connect(function(player)
	local tool = player.Backpack:FindFirstChild("Magic Finix Amber")

	if tool and player.Character then
		local animation = tool.LocalScript.Animation
		local character = player.Character
		local humanoid = character.Humanoid

		tool.Handle.Attachment.Fire.Enabled = false

		character.PrimaryPart.Anchored = true
		humanoid.WalkSpeed = 0
		humanoid.JumpHeight = 0

		local clonedBackground = background:Clone()
		clonedBackground.Name = "localBackground"
		clonedBackground.CFrame = character.PrimaryPart.CFrame * CFrame.new(0, 0, 2)
		clonedBackground.Rotation = character.PrimaryPart.Rotation
		clonedBackground.Parent = workspace

		local cloneeffect1 = effect:Clone()
		cloneeffect1.Parent = character.RightHand

		local cloneeffect2 = effect:Clone()
		cloneeffect2.Parent = character.LeftHand

		local music = clonedBackground.MagicWinx
		music.Playing = true

		local track = humanoid.Animator:LoadAnimation(animation)
		track:Play()
		task.wait(3)

		cloneeffect1.Enabled = true
		cloneeffect2.Enabled = true
		task.wait(1.5)
		cloneeffect1.Enabled = false
		cloneeffect2.Enabled = false

		local shirtID = shirt.ShirtTemplate
		character.Shirt.ShirtTemplate = shirtID
		character.Pants.PantsTemplate = "rbxassetid://15724231382"
		task.wait(2)

		local pantsID = pants.PantsTemplate
		character.Pants.PantsTemplate = pantsID
		task.wait(3.75)

		local wing_lclone = wing_l:Clone()
		wing_lclone.Handle.AccessoryWeld.Part1 = character.UpperTorso
		wing_lclone.Parent = character

		local wing_rclone = wing_r:Clone()
		wing_rclone.Handle.AccessoryWeld.Part1 = character.UpperTorso
		wing_rclone.Parent = character
		task.wait(1)

		local crownclone = crown:Clone()
		crownclone.Handle.AccessoryWeld.Part1 = character.Head
		crownclone.Parent =  character
		task.wait(2.5)

		cloneeffect1.Enabled = true
		cloneeffect2.Enabled = true
		task.wait(1)
		cloneeffect1.Enabled = false
		cloneeffect2.Enabled = false
		task.wait(6)

		clonedBackground:Destroy()

		humanoid.WalkSpeed = 16
		humanoid.JumpHeight = 7.2
		character.PrimaryPart.Anchored = false

		tool:Destroy()
	else
		warn("Magic Finix Amber does not exist in player's backpack!")
	end
end)
1 Like

It shows me that I don’t have it in my backpack. i will send script with that.

1 Like
local changeEvent = game.ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
local service = game:GetService("Players")
local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")
local tool = game.ReplicatedStorage["Magic Finix Amber"]:Clone()
changeEvent.OnServerEvent:Connect(function(player, chosenCharacter)
	if charsFolder:FindFirstChild(chosenCharacter) then
		local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
		local plrChar = player.Character

		if newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.HumanoidRootPart
			newChar:SetPrimaryPartCFrame(plrChar.HumanoidRootPart.CFrame)
		elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.Torso
			newChar:SetPrimaryPartCFrame(plrChar.Torso.CFrame)
		end

		if plrChar:FindFirstChild("Animate") then
			local anim = plrChar:FindFirstChild("Animate")
			anim:Clone().Parent = newChar
		end

		if plrChar:FindFirstChild("Health") and not newChar:FindFirstChild("Health") then
			plrChar.Health:Clone().Parent = newChar
		end

		player.Character = newChar

		local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
		local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

		if rootPart and plrRoot then
			rootPart.CFrame = plrRoot.CFrame
		end

		newChar.Parent = game.Workspace
		if player.Character.Name == "Amber" then
			tool.Parent = player.Backpack
		end
		-- Zachowanie nicku gracza
		player.Character.Name = player.Name
		player.Character:WaitForChild("Humanoid").DisplayName = player.Name
	end
end)local changeEvent = game.ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
local service = game:GetService("Players")
local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")
local tool = game.ReplicatedStorage["Magic Finix Amber"]:Clone()
changeEvent.OnServerEvent:Connect(function(player, chosenCharacter)
	if charsFolder:FindFirstChild(chosenCharacter) then
		local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
		local plrChar = player.Character

		if newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.HumanoidRootPart
			newChar:SetPrimaryPartCFrame(plrChar.HumanoidRootPart.CFrame)
		elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.Torso
			newChar:SetPrimaryPartCFrame(plrChar.Torso.CFrame)
		end

		if plrChar:FindFirstChild("Animate") then
			local anim = plrChar:FindFirstChild("Animate")
			anim:Clone().Parent = newChar
		end
		
		if plrChar:FindFirstChild("Health") and not newChar:FindFirstChild("Health") then
			plrChar.Health:Clone().Parent = newChar
		end
		
		player.Character = newChar
		
		local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
		local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

		if rootPart and plrRoot then
			rootPart.CFrame = plrRoot.CFrame
		end

		newChar.Parent = game.Workspace
		if player.Character.Name == "Amber" then
			tool.Parent = player.Backpack
		end
		-- Zachowanie nicku gracza
		player.Character.Name = player.Name
		player.Character:WaitForChild("Humanoid").DisplayName = player.Name
	end
end)
1 Like

That most likely explains the problems you’re having. I recommend you double-check the Tool’s name to see if there are any mistakes that could be breaking the script

1 Like
local changeEvent = game.ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
local service = game:GetService("Players")
local charsFolder = game.ReplicatedStorage:WaitForChild("Characters")
local tool = game.ReplicatedStorage["Magic Finix Amber"]:Clone()
changeEvent.OnServerEvent:Connect(function(player, chosenCharacter)
	if charsFolder:FindFirstChild(chosenCharacter) then
		local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
		local plrChar = player.Character

		if newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.HumanoidRootPart
			newChar:SetPrimaryPartCFrame(plrChar.HumanoidRootPart.CFrame)
		elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.Torso
			newChar:SetPrimaryPartCFrame(plrChar.Torso.CFrame)
		end

		if plrChar:FindFirstChild("Animate") then
			local anim = plrChar:FindFirstChild("Animate")
			anim:Clone().Parent = newChar
		end

		if plrChar:FindFirstChild("Health") and not newChar:FindFirstChild("Health") then
			plrChar.Health:Clone().Parent = newChar
		end

		player.Character = newChar

		local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
		local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

		if rootPart and plrRoot then
			rootPart.CFrame = plrRoot.CFrame
		end

		newChar.Parent = game.Workspace
		if player.Character.Name == "Amber" then
			tool.Parent = player.Backpack
		end
		-- Zachowanie nicku gracza
		player.Character.Name = player.Name
		player.Character:WaitForChild("Humanoid").DisplayName = player.Name
	end
end
1 Like

You have this written:

if player.Character.Name == "Amber" then
		tool.Parent = player.Backpack
end

Is your character named Amber?

1 Like

Why would :WaitForChild() be causing any of the problems OP is experiencing?

1 Like

WaitForChild isn’t meant to be used in server scripts since for the server everything is loaded at once

1 Like

as a character in workspace
Zrzut ekranu (33)
Zrzut ekranu (32)

1 Like

I suggest you try this:

local changeEvent = game.ReplicatedStorage:WaitForChild("ChangePlayerCharacter")
local service = game:GetService("Players")
local charsFolder = game.ReplicatedStorage:WaitForChild("Characters"
changeEvent.OnServerEvent:Connect(function(player, chosenCharacter)
	if charsFolder:FindFirstChild(chosenCharacter) then
		local newChar = charsFolder:FindFirstChild(chosenCharacter):Clone()
		local plrChar = player.Character

		if newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.HumanoidRootPart
			newChar:SetPrimaryPartCFrame(plrChar.HumanoidRootPart.CFrame)
		elseif newChar:FindFirstChild("Torso") and not newChar:FindFirstChild("HumanoidRootPart") then
			newChar.PrimaryPart = newChar.Torso
			newChar:SetPrimaryPartCFrame(plrChar.Torso.CFrame)
		end

		if plrChar:FindFirstChild("Animate") then
			local anim = plrChar:FindFirstChild("Animate")
			anim:Clone().Parent = newChar
		end

		if plrChar:FindFirstChild("Health") and not newChar:FindFirstChild("Health") then
			plrChar.Health:Clone().Parent = newChar
		end

		player.Character = newChar

		local rootPart = newChar:FindFirstChild("HumanoidRootPart") or newChar:FindFirstChild("Torso")
		local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")

		if rootPart and plrRoot then
			rootPart.CFrame = plrRoot.CFrame
		end

		newChar.Parent = game.Workspace
		if player.Character.Name == "Amber" then
			local tool = game.ReplicatedStorage["Magic Finix Amber"]:Clone()
			tool.Parent = player.Backpack
		end
		-- Zachowanie nicku gracza
		player.Character.Name = player.Name
		player.Character:WaitForChild("Humanoid").DisplayName = player.Name
	end
end

Since I noticed you were only cloning the Tool once outside the function

Edit: Made a small correction

1 Like

still not working :white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart::white_heart:

1 Like

It would help a lot if you explained what’s not working though

Are you getting any errors in the output?

1 Like

I get still warn that player has not a tool

1 Like