Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make script, which'll get sword to player, who touch brick?

Asked by 5 years ago

Hello! I am creating sword arena (I'm scripting beginner) and I already did "teleport on touch". This brick teleports you to Arena, but I want to add, that, when you touch brick, you'll get "Sword" (Classic by Roblox),

so please, help me with script and also, where to put Sword in Explorer and all these scripts :)

Thank you, if you need more information, ask me!

Also code, which's already in that brick: local part = script.Parent

local part = script.Parent



part.Touched:Connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid") then

hit.Parent.Head.CFrame = CFrame.new(-416, 77.9, 187.6)

end

part.BrickColor = BrickColor.new("Black")

wait(0.2)

part.BrickColor = BrickColor.new("White")

end)

1 answer

Log in to vote
0
Answered by 5 years ago

Here this is an example of what you would want:

local sword = script.Parent.Sword local brick = script.Parent

brick.Touched:Connect(function(hit)
        local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Try to find the player from the character.

        if player then
            if player.Backpack:FindFirstChild(sword.Name) then return end -- Do nothing if we find the sword in their backpack.
            local clone = sword:Clone()
            clone.Parent = player.Backpack
        end
end)
0
It's working! Thank you :) How happy can you be, that you know all these scritps. May I ask you, where do you started and where to learn? SloveniaVideo 5 — 5y
0
I started with a Roblox video. I always had wanted to learn to script so I started with this video: https://www.youtube.com/watch?v=0LiaEDui2vE and from there I really just learned around. Watching more videos and learning by myself. Of course there is a lot to still learn and that's my main focus: learning. Roblox Lua is very easy to lean. I think everyone should learn it on Roblox. namespace25 594 — 5y
0
Do you have your own games? And sorry, I'd like to mark your answer as "helped" but i can't find button. The site doesn't show it to me. SloveniaVideo 5 — 5y
0
Yes. I have one game and I am working on another for a police group with 14K+ members. namespace25 594 — 5y
Ad

Answer this question