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)
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)
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
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"
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