New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do I make It so when a player touches a brick it makes another brick spawn in?

Asked by 9 days ago

I am Very new to scripting I have Tried many trigger events and looking up this exact question but I cant find it.

1 answer

Log in to vote
1
Answered by
Ziannea 469 Moderation Voter
9 days ago

i assume you already know about how events, the .Touched event, and debounces (aka cooldowns) work

if you don't, you should read these articles first (in this order)

https://developer.roblox.com/en-us/articles/events

https://developer.roblox.com/en-us/articles/detecting-collisions

https://developer.roblox.com/en-us/articles/Health-Pickups

-- in a script inside the part...

local canSpawnBrick = true
local cooldown = 5
local spawnPosition = Vector3.new(0, 10, 0) -- you can set this whereever

local function onTouched(hit)
    local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
    if humanoid and canSpawnBrick == true then -- we don't actually need the humanoid, we just want to know if a character touched it
        local newBrick = Instance.new("Part") -- make the new brick
        newBrick.Position = spawnPosition
        newBrick.Parent = workspace
        canSpawnBrick = false -- activate the cooldown
        wait(cooldown)
        canSpawnBrick = true
    end
end

script.Parent.Touched:Connect(onTouched)
0
Thank you I will Try this Scallywagpugzy 0 — 9d
0
But I have a question Scallywagpugzy 0 — 9d
0
How to make it so when that brick spawns in it has other objects that come with it on top of it like for example, the part spawns in and it has trees on top of it when it come is Scallywagpugzy 0 — 9d
0
you can create a model, and then clone that model into the workspace with all of its parts Ziannea 469 — 9d
View all comments (3 more)
0
I am Kind of confused with the script do you know if you can just type out the full normal script I started Scripting 4 days ago sorry Scallywagpugzy 0 — 9d
0
Like the script that is at the top Scallywagpugzy 0 — 9d
0
Because I dont Think I did It right Scallywagpugzy 0 — 9d
Ad

Answer this question