How do i make button that will spawn an npc

  1. i want to know how do i make button that will spawn npc on click

  2. i am newbier in scripting

  3. i couldnt find any tutorial

i would like to get help! thanks

1 Like

yuh uh i got you cuh so uhh what you would do is

get an npc
put it in server storage
insert a server script as a child in a click detector that is in a part
change the click detector properties to your liking

and put this into the script inside of the click detector

local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function()
	local ServerStorage = game:GetService("ServerStorage")
	local Work = game:GetService("Workspace")

	local Character = ServerStorage:FindFirstChild("Dummy"):Clone() -- Put your NPC name here. \\
	Character.Parent = Work -- Where you want the NPC to be in.
	
	Character:FindFirstChild("HumanoidRootPart").CFrame = ClickDetector.Parent.CFrame * CFrame.new(0, 3, 0) -- Teleports the NPC
end)
2 Likes

First of all you shouldn’t let a client decide when to spawn characters on the server due to exploiting reasons.

But if you do want to do it you would just connect to the MouseButton1Down event of a TextButton and fire an event to the server. From there you could use the code inside of the function vendetta gave you.

1 Like

Thanks! helped me a lot ! and sorry for a bad grammar :slight_smile:

Hey vendetta can you teach me how to script in Lua? Just send me a message please if interested

i dont really know what to do but if i were you i would look at youtube tutorials and look at how free models work because thats what i did

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.