generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Point a model towards a target?

Previous Thread :: Next Thread 
Badfitz100 is not online. Badfitz100
Joined: 03 Nov 2010
Total Posts: 12591
21 Dec 2014 11:44 AM
I've tried doing this for hours

I'm editing a basic model rotation script so it'll point towards a target with no success.

script:

wait(.3)
sp = script.Parent
gunParts = script.Parent.Gun
gun = gunParts["Single heavy"]
main = gunParts.Main

function aim(mod,center,pointto)
local parts ={}
local function scan(parent)
for _,obj in pairs(parent:GetChildren()) do
if (obj:IsA("BasePart")) then
table.insert(parts,obj)
end
scan(obj)
end
end
scan(mod)
for _,part in pairs(parts) do
part.CFrame = CFrame.new((center.Y*part.CFrame.Y), pointto) -- Credit to oysi93 for this equation thing
end
end


while wait() do
aim(sp, sp.Base:GetModelCFrame(), workspace.Target.Position)
end

can someone just fix it, I'm not in the mood to go through all the errors.

Prepare for Rolf's water-laden bovine bladder!
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
21 Dec 2014 11:45 AM
Just set the primary part's CFrame instead?
Report Abuse
Badfitz100 is not online. Badfitz100
Joined: 03 Nov 2010
Total Posts: 12591
21 Dec 2014 11:50 AM
Wouldn't that just keep on rotating because I'm adding to the rotation?

Prepare for Rolf's water-laden bovine bladder!
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
21 Dec 2014 11:53 AM
game.Model:SetPrimaryPartCFrame(game.Model.PrimaryPart.CFrame.p, lookatPosition)
Report Abuse
Badfitz100 is not online. Badfitz100
Joined: 03 Nov 2010
Total Posts: 12591
21 Dec 2014 11:58 AM
function aim(mod,center,pointto)
local parts ={}
local function scan(parent)
for _,obj in pairs(parent:GetChildren()) do
if (obj:IsA("BasePart")) then
table.insert(parts,obj)
end
scan(obj)
end
end
scan(mod)
for _,part in pairs(parts) do
sp.Base.PrimaryPart = sp.Base.BaseM
sp.Base:SetPrimaryPartCFrame(sp.Base.PrimaryPart.CFrame.p, pointto)
end
end


while wait() do
aim(sp, sp.Base:GetModelCFrame(), workspace.Target.Position)
end

17:57:58.609 - Unable to cast Vector3 to CoordinateFrame
17:57:58.609 - Script 'Workspace.Model.Model.shootingMain', Line 22 - global aim
17:57:58.610 - Script 'Workspace.Model.Model.shootingMain', Line 28
17:57:58.610 - Stack End

Prepare for Rolf's water-laden bovine bladder!
Report Abuse
Badfitz100 is not online. Badfitz100
Joined: 03 Nov 2010
Total Posts: 12591
21 Dec 2014 11:59 AM
wait(.3)
sp = script.Parent
gunParts = script.Parent.Gun
gun = gunParts["Single heavy"]
main = gunParts.Main
mainWeld = main:FindFirstChild("Weld1")
mainWeldBase = main:FindFirstChild("Weld2")

function aim(mod,center,pointto)
sp.Base.PrimaryPart = sp.Base.BaseM
sp.Base:SetPrimaryPartCFrame(sp.Base.PrimaryPart.CFrame.p, pointto)
end


while wait() do
aim(sp, sp.Base:GetModelCFrame(), workspace.Target.Position)
end

shortened it down, same error

Prepare for Rolf's water-laden bovine bladder!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image