Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trying to make a script that spawns a model from the ServerStorage infront of a Torso of a model?

I'm thinking of game.ServerStorage.Sentry:Clone().Parent = game.Workspace.Engineer.Torso.Position but it isn't working.

If anyone can help me complete this script it would be greatly appreciated.

2 comments

0

let me know if my answer works because I am unable to test it right now

0

Are you sure you have the spelling right for these things? My second script should definitely work if you got the spelling and hierarchy right.

1 answer

✓ Accepted answer

So this is the one that works with a model:

workspace.DescendantAdded:Connect(function(descendant)
	if descendant.Name=="Engineer" then
		game.ServerStorage.Sentry:Clone().Parent = descendant.Torso
	end	
	descendant.Torso.Sentry.PrimaryPart.CFrame = CFrame.new(thing.Torso.CFrame.X+5,thing.Torso.CFrame.Y,thing.Torso.CFrame.Z)
end)

This will look for an engineer if one was added, but if it already exists, then you can just have the script be:

local thing = workspace:FindFirstChild("Engineer")
game.ServerStorage.Sentry:Clone().Parent = thing.Torso
thing.Torso.Sentry.PrimaryPart.CFrame = CFrame.new(thing.Torso.CFrame.X+5,thing.Torso.CFrame.Y,thing.Torso.CFrame.Z)

Just change the CFrame.new(x,y,z) to whatever makes it go in front of your model

And this is the one that works with a single part:

workspace.DescendantAdded:Connect(function(descendant)
	if descendant.Name=="Engineer" then
		game.ServerStorage.Sentry:Clone().Parent = descendant.Torso
	end	
	descendant.Torso.Sentry.CFrame = CFrame.new(thing.Torso.CFrame.X+5,thing.Torso.CFrame.Y,thing.Torso.CFrame.Z)
end)

This will look for an engineer if one was added, but if it already exists, then you can just have the script be:

local thing = workspace:FindFirstChild("Engineer")
game.ServerStorage.Sentry:Clone().Parent = thing.Torso
thing.Torso.Sentry.CFrame = CFrame.new(thing.Torso.CFrame.X+5,thing.Torso.CFrame.Y,thing.Torso.CFrame.Z)

Just change the CFrame.new(x,y,z) to whatever makes it go in front of your model

12 comments

0

doesn't work

0

actually it does work with a singular part but with the sentry model im using it doesnt work.

0

Oh you should have said the sentry was a model

0

Ok it should work now, as long as you set the PrimaryPart of Sentry to somehting

0

My script is fine, you need to go into Sentry's properties and set the PrimaryPart to something within Sentry

0

Well I set a part of the sentry to the PrimaryPart and it cloned the whole thing and it didn't go infront of the model

0

You need to set the PrimaryPart to a part in the middle of the model

0

also updated my scripts to let it go infront of the model, the only thing you'll need to do is change the x y z values to make it go in front of your model. I can't do that because I don't have any more information than the stuff that you gave me

0

thanks

0

Wait can you repaste the old script that works with a singular part?

0

Just edited it so you have both now

0

Make sure to re-accept it otherwise people will think it's still unanswered

This discussion is preserved as it was. New answers, comments, and votes are closed.