I have found an error when making tools for my game. I am making a wizard game, which uses potions. When the player finishes making their potion, I want to put the potion into the player's backpack; however, when the potion's script (I have tried both a local script, and a server script) is always reset back to the default source:
print("Hello World!")
My question in simple terms is this: Why does the source get reset when I add the potion into the player's backpack (from ServerStorage)?
My second question is this: Does the tool have to be in ReplicatedStorage in order for the script not to be reset, or am I just experiencing a bug?
The code I have in my (now local) script is as follows:
-- made by oCrxptic local potionType = script.Parent:WaitForChild("TYPE").Value script.Parent.Activated:Connect(function() game.ReplicatedStorage.Potions.Actions.Drank:FireServer(potionType) end)
The code is meant to be called when the player wants to drink the potion they have brewed.
Edit:
I thought that I would include the code in which I change the potion's parent, and in a way, the script's:
game.ReplicatedStorage.RemoteEvents.PotionFinished.OnServerEvent:Connect(function(player) local potionType = script.Parent:FindFirstChild("Potion Type").Value if potionType == nil or potionType == "" then potionType = "mundane" -- Has no effects, error. end local potion = game.ServerStorage.Potions[potionType.." Potion"]:Clone() potion.Parent = player.Backpack end)
I did not want to add the ENTIRE script, as it is fairly lengthy.This script is inside of the cauldron.
If you wish for me to provide more information, please leave a comment with the specific information you are requesting, and I will update the question.
As always, all help is appreciated. Thank you in advance!
NotedAPI said it has something to do with team create, so imma go with that