I'm trying to make it so that the campfire spawns at the player but it always spawns somewhere else does anyone know how to fix this? This is in a local script because it's using a GUI.
local player = game.Players.LocalPlayer local character = game.Players.LocalPlayer.Character local Campfire = game.ReplicatedStorage.Campfire script.Parent.MouseButton1Click:connect(function() if player.Sticks.Value >= 2 then if player.Stone.Value >= 1 then player.Stone.Value = player.Stone.Value -1 player.Sticks.Value = player.Sticks.Value -2 local ClonedCampfire = Campfire:Clone() ClonedCampfire.Parent = game.Workspace ClonedCampfire.Position = character.Position end end end)
You're trying to set the campfire's position to a model. Model's don't have a position value, but the things inside of the model do. You should notice that this creates an error on the developer console (press F9 in-game when you try to spawn the campfire)
local player = game:GetService("Players").LocalPlayer local character = game:GetService("Players").LocalPlayer.Character local Campfire = game:GetService("ReplicatedStorage"):WaitForChild("Campfire") script.Parent.MouseButton1Click:Connect(function() if player.Sticks.Value >= 2 and player.Stone.Value >= 1 then player.Stone.Value = player.Stone.Value -1 player.Sticks.Value = player.Sticks.Value -2 local ClonedCampfire = Campfire:Clone() ClonedCampfire.Parent = workspace ClonedCampfire:MoveTo(Character:WaitForChild("HumanoidRootPart").Position + (Character:WaitForChild("HumanoidRootPart").CFrame.lookVector * 3)) end end)
You may notice that I used :MoveTo(), this is a function that allows you to move every part of a model with one function. You can read more about it here
In order to make it spawn in front of the player, you'll want to use CFrame.lookVector.