I want to make an NPC Spawner with button. When we press the button then the npc spawns. Have a clickdetector in button but still nothing "MouseClick" is not a valid member of a part. This is an error what i get first in the output once. If i click i dont get more errors just don't spawn the NPC.
local Clicker = script.Parent --ClickDetector local Object = game.ReplicatedStorage.Put --Put is my object in replicatedstorage local ObjectSpawn = game.Workspace.ObjectSpawn --Object Spawner Clicker.MouseClick:Connect(function() local CloneObject = Object:Clone() CloneObject.Parent = game.Workspace CloneObject:MoveTo(ObjectSpawn.Position) end)
Try this, this is my template that has always worked for me.
function onClicked() end script.Parent.ClickDetector.MouseClick:connect(onClicked)
local Object = game.ReplicatedStorage.Put --Put is my object in replicatedstorage local ObjectSpawn = game.Workspace.ObjectSpawn --Object Spawner function onClicked() local CloneObject = Object:Clone() CloneObject.Parent = game.Workspace CloneObject:MoveTo(ObjectSpawn.Position) end script.Parent.ClickDetector.MouseClick:Connect(onClicked)