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

can i please have help makeing a button wen clicked it spawns a npc? [closed]

Asked by 4 years ago

i tried to make a stand and stuff i need help with a code please

0
You need to try your self first and show us how you did it ew_001 58 — 4y
0
Is... Is that a request? SoftlockedUnderZero 668 — 4y
0
Please, isn't a request site. If you want help put your script with your question. NiniBlackJackQc 1562 — 4y
0
i tryed i just cant find a way yo make it jablesgamer1 2 — 4y
View all comments (2 more)
0
to* jablesgamer1 2 — 4y
0
i tryed to make it im just so new ro lua jablesgamer1 2 — 4y

Closed as Not Constructive by NiniBlackJackQc, Torren_Mr, and User#5423

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

Ok, in order to do this you are gonna use a RemoteEvent. In the localscript inside of the textbutton to spawn the NPC put the following:

local rem = game:GetService('ReplicatedStorage'):WaitForChild('SpawnNPC') --This gets our remote event

script.Parent.MouseButton1Click:connect(function()
    rem:FireServer() --Fires it
end)

now in the ServerScriptService, put the following in a script:

local remote = game:GetService('ReplicatedStorage'):WaitForChild('SpawnNPC')

remote.OnServerEvent:connect(function()
    local npc = game.ReplicatedStorage:WaitForChild('Soldier') --Our NPC in this case is a soldier
    npc:Clone().Parent = workspace --Spawns the NPC into workspace
end)

I hope this helps you out, but please remember that this isn't a request site and the next time you have a question put in your code so we can help you out

0
Maybe use the InsertService to insert a NPC into the game? harstud 218 — 4y
Ad