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

How do I add one of those talking NPC's to my game, and make it give you a weapon?

Asked by 10 years ago

How do I add a NPC bot that gives you the weapon that I want to add, also how do I change the way that bot looks?

2 answers

Log in to vote
0
Answered by 10 years ago

There's a tutorial on the Roblox Wiki, maybe next time try just search things before you ask on here. http://wiki.roblox.com/index.php/Dialog_Shop_Tutorial

Follow the tutorial - I've edited out the price bits of the script for you, it should work, so just put this under 'Dialog' and also simply change 'ChoiceA', 'ChoiceB' and 'ChoiceC' to whatever you named your Dialog Choices to, same with Weapon1 Weapon2 and Weapon3.

However if you just want one item in the Dialog then just remove the 'elseif' parts.

local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player, choice)

    if choice == script.Parent.DialogChoice.ChoiceA then
            game.ReplicatedStorage.Weapon1:Clone().Parent = player.Backpack
        end

    elseif choice == dialog.DialogChoice.ChoiceB then
            game.ReplicatedStorage.Weapon2:Clone().Parent = player.Backpack
        end

    elseif choice == dialog.DialogChoice.ChoiceC then
            game.ReplicatedStorage.Weapon3:Clone().Parent = player.Backpack
        end
    end
end)
0
ok thank you i am no scripter, but i will do as you say :D and yes i only want one weapon guy5572 0 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Well, you can try something like this, it's not npc, but if you want to make a sword fighting game it works just fine.

Directions: Put a LinkedSword into Lighting and name it "Sword". Next, put a script into a brick and anchor the brick or part. Next, type this into the script.

script.Parent.Touched:connect(function(hit) local find = hit.Parent:FindFirstChild("Humanoid") if find then local player = game.Players:GetPlayerFromCharacter(hit.Parent) local findS = player.Backpack:FindFirstChild("Sword") if not findS then local sword = game.Lighting.Sword:Clone() sword.Parent = player.Backpack end end if not find then print('no humanoid') end end)

0
Or copy. Hope it worked! LoadingBrick 0 — 10y

Answer this question