i tried to make a stand and stuff i need help with a code please
COMMUNITY QUESTION
can i please have help makeing a button wen clicked it spawns a npc?
1 answer
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
1 comment
0
Maybe use the InsertService to insert a NPC into the game?
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
You need to try your self first and show us how you did it
Is... Is that a request?
Please, isn't a request site. If you want help put your script with your question.
i tryed i just cant find a way yo make it
to*
i tryed to make it im just so new ro lua