Update: The whole system has now been overhauled and functions properly. Here’s the code if anyone’s interested:
LocalScript inside of inventory slot.
local Item
script.Parent.MouseButton1Click:Connect(function(player)
if script.Parent.Parent:FindFirstChild("Equipable") and script.Parent.Parent.Equipable.Value == true and game.ReplicatedStorage.ItemEquipped.Value == false then
game.ReplicatedStorage.ItemEquipped.Value = true
script.Parent.Parent.Equipable.Value = false
Item = script.Parent.Parent.ItemName.Value
game.ReplicatedStorage.Tools.EquipTool:FireServer(Item)
script.Parent.Parent.BackgroundColor3 = Color3.new(0.14902, 1, 0)
script.Parent.Parent.Parent.Parent.Visible = false
else if script.Parent.Parent:FindFirstChild("Equipable") and script.Parent.Parent.Equipable.Value == false and game.ReplicatedStorage.ItemEquipped.Value == true then
script.Parent.Parent.Equipable.Value = true
game.ReplicatedStorage.ItemEquipped.Value = false
game.ReplicatedStorage.Tools.DestroyTool:FireServer(Item)
Item = nil
script.Parent.Parent.BackgroundColor3 = Color3.new(0,0,0)
script.Parent.Parent.Parent.Parent.Visible = false
end
end
end)
ServerScript counterpart
local Tool
game.ReplicatedStorage.Tools.EquipTool.OnServerEvent:Connect(function(player,Item)
Tool = game.ReplicatedStorage.Tools[Item]:Clone()
Tool.Parent = player.Character
Tool.Parent = player.Backpack
Tool.Parent = player.Character
end)
game.ReplicatedStorage.Tools.DestroyTool.OnServerEvent:Connect(function(player,Item)
local Dupe = Tool:Clone()
Tool:Destroy()
Tool = game.ReplicatedStorage.Tools[Item]
Tool:Destroy()
Dupe.Parent = game.ReplicatedStorage.Tools
Tool = nil
end)
LocalScript filling up bucket with water
local Content = script.Parent.Handle.Content
local Full = script.Parent:WaitForChild("Water").Value
local Item = script.Parent.BucketItem
script.Parent.Parent.Humanoid.Swimming:Connect(function()
if not Full then
print(Item.Value)
game.ReplicatedStorage.Tools.BucketEvents.WaterFilling:FireServer(Item,Content)
Full = true
end
end)
ServerScript counterpart
game.ReplicatedStorage.Tools.BucketEvents.WaterFilling.OnServerEvent:Connect(function(player,Item,Content)
if Item.Value == "Flour" then
Item = "BreadDough"
Content.Transparency = 0
Content.Material = Enum.Material.Mud
Content.Color = Color3.new(0.92549, 0.682353, 0.435294)
else
Content.Transparency = 0.35
Content.Material = Enum.Material.Glass
Content.Color = Color3.new(0, 0.682353, 1)
Item.Value = "Water"
end
end)
LocalScript updating the visual content inside the bucket
local RS = game.ReplicatedStorage
RS.Tools.BucketEvents.GetCurrentBucketItem.Event:Connect(function(Item)
local CurrentItem = script.Parent.BucketItem
RS.Tools.BucketEvents.UpdateBucketContents:FireServer(Item,CurrentItem)
end)
ServerScript counterpart
local ContentInfo = {
["Flour"] = {
Material = Enum.Material.Snow,
Color = Color3.new(0.960784, 1, 0.862745),
TP = 0
}
}
game.ReplicatedStorage.Tools.BucketEvents.UpdateBucketContents.OnServerEvent:Connect(function(player,Item,CurrentItem)
local Content = player.Character.Bucket.Handle.Content
local Info = ContentInfo[Item]
if Item == "Flour" and CurrentItem.Value == "Water" then
CurrentItem.Value = "BreadDough"
Content.Transparency = 0
Content.Material = Enum.Material.Mud
Content.Color = Color3.new(0.92549, 0.682353, 0.435294)
else
CurrentItem.Value = Item
Content.Material = Info.Material
Content.Color = Info.Color
Content.Transparency = Info.TP
end
end)