Spawning an NPC using a Tool

Yes, because it’s script that mean you’re using this script on server side not client side.

I want it to be serversided though, so everyone can see it be spawned in.

Where is this tool?
(30 chars)

Because i wanna know why you try to set parent

The tool is in the StarterPack, which ends up in everyones backpack.

So, no need to set parent now. remove that line away.

This is what I have left now:
local tool = Instance.new(“Tool”)

tool.RequiresHandle = false

function onActivation(player)

local d=game.ReplicatedFirst.Player:Clone()

d.Parent=workspace

d:MoveTo(game:GetService’Players’[player].Character:FindFirstChild’HumanoidRootPart’.Position)

end

tool.Activated:Connect(onActivation)


Which still doesn’t do what I want it to, just every single way I try to do it, it fails.

Why you need to create new Tool

Oh wait:


tool = script.Parent

function onActivation(player)

local d=game.ReplicatedFirst.Player:Clone()

d.Parent=workspace

d:MoveTo(game:GetService’Players’[player].Character:FindFirstChild’HumanoidRootPart’.Position)

end

tool.Activated:Connect(onActivation)

Why put your npc on replicatedfirst

Where would it be better to put it?

ReplicatedStorage is a good place to put it

If you want it to access by server only put it on ServerStorage

You should probably use some system with remote events, place your current script into a local script but instead fire the event from there. Place the cloning portion of your script in serverscriptstorage and call the function when the events fired. This is the best method.

1 Like

If we do like that, the problem is, WE CAN’T TRUST CLIENT. if exploiter spam remote event that mean many npc will got CLONED and will cause lag to another player and server.

I no longer know what to do, I’ve done all the ways people recommended. Still no progress.

The case is, he’s asking for help on a script. Security vulnerabilities can be addressed later.

1 Like

If you’d like I can personally help for free. I can DM you a functioning script.

1 Like

Help me to solve this please, i wanna addressed my Security vulnerabilities

What do you mean?

Go ahead. That’s fine with me.?