Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cant Place Correctly?

Asked by 10 years ago

I've been trying to make a place tool that places my NPC, but I can't get the NPC to pop up with its arms. Anyone know how to fix that? Heres the place script, btw, the NPC is fully animated.

wait()
local s = script.Parent.Selection
local p = script.Parent.Model
local canplace = false
local selected = false
local pos = Vector3.new(0,0,0)
local team = script.Parent.Parent.Parent.TeamColor
local larm = p["Left Arm"]
local rarm = p["Right Arm"]

script.Parent.Selected:connect(function(mouse)
selected = true
player = script.Parent.Parent.Parent
s.Parent = player.Character
mouse.Button1Down:connect(function()
if canplace then
s:Remove()
p.Parent = workspace
p:MakeJoints()
p:MoveTo(pos)
script.Parent:Remove()
end
end)
while wait() do
if not selected then return false end
pos = Vector3.new(math.floor(mouse.Hit.p.X),math.floor(mouse.Hit.p.Y),math.floor(mouse.Hit.p.Z))
s.Position = pos+Vector3.new(0.5,0,0.5)
part,pos = workspace:FindPartOnRay(Ray.new(s.Position,Vector3.new(0,-0.2,0)),player.Character)
if part and part.BrickColor ~= BrickColor.Black() then
canplace = true
s.BrickColor = BrickColor.Green()
else
canplace = false
s.BrickColor = BrickColor.Red()
end
end
end)

script.Parent.Deselected:connect(function(m)
selected = false
s.Parent = script.Parent
end)

Answer this question