For example, if a player has a frying pan, they should be able to click on the stove part and have the frying pan taken from their inventory and placed on the stove.
I’m probably not even close.
all i have so far is:
local click = script.Parent
local player
if player.Backpack:FindFirstChild(“THEPAN2”) then
player.Character.THEPAN2: CFrame (68.171, 3.441, 112.9)
end
1 Like
try
Character.ThePan.Parent = workspace
workspace.ThePan.Handle.Position = Stove.Position
1 Like
no sorry its not working for me.
1 Like
You can use Mouse.Target when the player clicks to see what part the mouse’s target is on. Then, you can simply move “ThePan” to that part’s position with a :MoveTo() (this will allow it to rest on top of the object).
well im not sure exactly how to code that. Basically, a player spawns in and they pick up a pan. Then i want them to be able to place it on a part with a click detector already on the part. So the player clicks on the click detector, the pan gets taken from the players inventory/backpack and placed on the part.
all i can come up with is:
local click = game.workspace.Stoves.Stove1.Ring1.ClickDetector
local player = game:GetService(“Players”)
local currentTool = “THEPAN2”
local currentTool = player.Backpack:FindFirstChildWhichIsA(‘Tool’)
if currentTool then
currentTool.Parent = game.Workspace
currentTool.THEPAN2.Position = game.workspace.Stoves.Stove1.Ring1
end
not working
Instead of parenting the tool you should parent the actual object.
currentTool.THEPAN2.Parent = workspace -- 'THEPAN2'` is now parented to workspace, not the tool.
-- now you can get THEPAN2 by indexing it through workspace or if you have a variable for it.
workspace.THEPAN2.Position = game.workspace.Stoves.Stove1.Ring1.Position
-- you forgot to change the position to the Ring1 position.