So I am making a cooking game, and when the player takes a Chicken out of the oven it gives him a cooked chicken tool, but that tool is not in his hand when he holds it, instead it is where it was before it was in replicated storage.
The script is pretty big, but all the tool stuff is in the two functions at the top, the only reason I included the rest is if you wanted to see it, but the problem is mainly the burnt and cooked functions.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DB = false
local proximityR = script.Parent
local proximityC = script.Parent.Parent.Parent.Cooked.ProximityPrompt
local proximityB = script.Parent.Parent.Parent.Burnt.ProximityPrompt
local ChickenModel = ReplicatedStorage.RawChicken
local ChickenSlice = ReplicatedStorage.RawChickenPiece
local OvenLight = game.Workspace.Oven1.OvenLight.SpotLight
local OvenHeaters = game.Workspace.Oven1.Heaters
local taken = false
--sounds
local Sizzle = script.Parent.Sizzle
local On = script.Parent.On
local Ding = script.Parent.CookedDing
local Door = script.Parent.Door
local Fire = script.Parent.Fire
--
function Cooked(Player)
proximityC.Enabled = false
taken = true
print("Cooked and ready!!")
OvenHeaters.Color = Color3.fromRGB(27, 42, 53)
OvenLight.Brightness = 0
Sizzle.Looped = false
Sizzle:Stop()
On.Looped = false
On:Stop()
ChickenSlice:Destroy()
local ChickenCTool = ReplicatedStorage.CookedChicken
local character = Player.Character or Player.CharacterAdded:Wait() -- gets the player's character
local humanoid = character:FindFirstChildOfClass("Humanoid") -- get the humanoid
ChickenCTool.Parent = Player.Backpack -- put in backpack
humanoid:EquipTool(ChickenCTool) --equip the tool
wait(1)
DB = false
end
function Burnt(Player)
print("bruv u burned it")
ChickenSlice:Destroy()
proximityB.Enabled = false
OvenHeaters.Color = Color3.fromRGB(27, 42, 53)
OvenLight.Brightness = 0
Sizzle.Looped = false
Sizzle:Stop()
On.Looped = false
On:Stop()
local ChickenBTool = ReplicatedStorage.BurntChicken
local character = Player.Character or Player.CharacterAdded:Wait() -- gets the player's character
local humanoid = character:FindFirstChildOfClass("Humanoid") -- get the humanoid
ChickenBTool.Parent = Player.Backpack -- put in backpack
humanoid:EquipTool(ChickenBTool) --equip the tool
wait(1)
DB = false
end
proximityB.Enabled = false
proximityC.Enabled = false
proximityR.Triggered:Connect(function(Player)
if not DB then
local Chicken = Player.Character:FindFirstChild("RawChicken")
if Chicken then
DB = true
--|Position and cloning|--
Chicken:Destroy()
ChickenSlice:Clone()
ChickenSlice.Parent = workspace
ChickenSlice.PrimaryPart = ChickenSlice.Union
ChickenSlice:SetPrimaryPartCFrame(CFrame.new(42.643, 2.057, -34.316))
proximityR.Enabled = false
--|Looks|--
OvenHeaters.Color = Color3.fromRGB(255, 107, 18)
OvenLight.Brightness = 100
--|Cooking|--
Door:Play()
wait(.5)
Sizzle:Play()
Sizzle.Looped = true
On:Play()
On.Looped = true
wait(5)
ChickenSlice.Union.Color = Color3.fromRGB(232, 198, 136)
proximityC.Enabled = true
print("ready")
proximityC.Triggered:Connect(Cooked)
Ding:Play()
wait(5)
--|Burnt|--
if not taken then
proximityC.Enabled = false
proximityB.Enabled = true
ChickenSlice.Union.Color = Color3.fromRGB(39, 39, 39)
proximityB.Triggered:Connect(Burnt)
print("Burning")
end
end
end
end)