Hello
I want to create a button that when you press it an object will be spawned. I currently have no idea how to do this. cuase I'm new to scripting. Thats also why i dont have codes orso. Thanks if you know
Kees
I will be helping you then, this would be like a tutorial but I do suggest you read some roblox wiki or other questions and answers before asking.
These are 2 way's to do this but I will show you the simple way;
Follow these steps;
- Insert a Part
- Make sure the part settings/properties are; Anchored = true, CanCollide = true
- Insert a ClickDetector into the part
- Insert a normal script into the ClickDetector
- Make the model/object you want to spawn
- Make sure the model and object is named and place it in the ReplicatedStorage
- Insert another part, make sure it has the same settings as the first part and name the part "ObjectSpawn"
Place ObjectSpawn where you want the Object to spawn
Place this code inside the script in ClickDetector;
local Clicker = script.Parent --ClickDetector local Object = game.ReplicatedStorage:WaitForChild("ObjectName") --Put your object name here local ObjectSpawn = game.Workspace:WaitForChild("ObjectSpawn") --Object Spawner Clicker.onClicked:Connect(function() --Fires on Click local CloneObject = Object:Clone() --Clones the Object CloneObject.Parent = game.Workspace -- Send's it to Workspace CloneObject.CFrame.p --Change this to Position IF the script doesn't work = ObjectSpawn.CFrame.p end)
This should spawn what you want spawned, if it doesn't work then change the last line to
CloneObject.Position = Vector3.new(ObjectSpawn.Position)
If this helped then please Accept Answer