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

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

Asked by 6 years ago

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.

0
let me know if my answer works because I am unable to test it right now SteamG00B 1633 — 6y
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. SteamG00B 1633 — 6y

1 answer

Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
6 years ago
Edited 6 years ago

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

0
doesn't work ErskinePierre 48 — 6y
0
actually it does work with a singular part but with the sentry model im using it doesnt work. ErskinePierre 48 — 6y
0
Oh you should have said the sentry was a model SteamG00B 1633 — 6y
0
Ok it should work now, as long as you set the PrimaryPart of Sentry to somehting SteamG00B 1633 — 6y
View all comments (8 more)
0
My script is fine, you need to go into Sentry's properties and set the PrimaryPart to something within Sentry SteamG00B 1633 — 6y
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 ErskinePierre 48 — 6y
0
You need to set the PrimaryPart to a part in the middle of the model SteamG00B 1633 — 6y
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 SteamG00B 1633 — 6y
0
thanks ErskinePierre 48 — 6y
0
Wait can you repaste the old script that works with a singular part? ErskinePierre 48 — 6y
0
Just edited it so you have both now SteamG00B 1633 — 6y
0
Make sure to re-accept it otherwise people will think it's still unanswered SteamG00B 1633 — 6y
Ad

Answer this question