Here I have a drink, that could be placed down anywhere. It has a feature of remembering its state of being opened.
The state of being opened or not is also saved throughout the process of the scripts. The problem is the prop version of the drink cannot send the bool to the cloned original drink.
First, player has the original drink. Once opened, bool value sets to true, which IsOpened = true.
Then, placing it down will have a fake version of the drink to be placed down. With a click detector and the saved bool value IsOpened from the original drink.
Finally, my problem occurs here, where the prop version’s saved bool value did not get transferred over to a brand new cloned drink parented back to the player.
I’ve tried attributes, an alternative to bool value, did not work!
Name of the drink: Canned Water
Prop’s script:
local Tool = game:GetService("ServerStorage")["Important Gears"]:WaitForChild("Canned Water")
local State = script.Parent.Opened.Value
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local NewTool = Tool:clone()
NewTool.Parent = player.Character
NewTool.IsOpened.Value = State
print(State)
print(NewTool.IsOpened.Value)
NewTool:SetAttribute("IsOpened", State)
print(player.Name .. "Picked up the drink!!")
local soundTable = {
17297659592,
}
local randomIndex = math.random(1, #soundTable)
local randomSoundId = soundTable[randomIndex]
NewTool.Handle.Place.SoundId = "rbxassetid://" .. randomSoundId
NewTool.Handle.Place:play()
if State then
print("its opened")
NewTool.Main.Enabled = true
NewTool.Opener:Destroy()
else
NewTool.Opener.Enabled = true
NewTool.Main.Enabled = false
print("its NOT opened")
end
script.Parent:Destroy()
end)
If any of you got an idea how I could fix this, hit me up please and thank you.