I want to make a TextButton that creates a part and sets the position to where the player is, if anything, slightly in front of it.
Here is the code I have so far:
function onclick() local player = game.Players.LocalPlayer local character = player.Character local mouse = player:GetMouse() local p = Instance.new("Part") local pos = character.LowerTorso.Position p.Parent = game.Workspace p.Position = Vector3.new(pos) end script.Parent.MouseButton1Click:Connect(onclick)
The script is a local script by the way. Any help would be appreciated! :)
EDIT: Oops! I'm an idiot lol! I was putting the Vector3 in "p.Position = Vector3.new(pos)". The solution is to have just "p.Position = pos". Sorry about that!
Oops! I'm an idiot lol! I was putting the Vector3 in "p.Position = Vector3.new(pos)". The solution is to have just "p.Position = pos". Sorry about that!
You can also use CFrame:
function onclick() local player = game.Players.LocalPlayer local character = player.Character local mouse = player:GetMouse() local p = Instance.new("Part") local pos = character.LowerTorso.Position p.Parent = game.Workspace p.CFrame = CFrame.new(pos) end script.Parent.MouseButton1Click:Connect(onclick)
Hope this helped!