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

Can someone please fix this script?

Asked by 10 years ago

I tried what my friend said about how I can add the Model ID number in the script to make it as a tool. What I want it to do is make the NPC give you tools, but from the model you create. Can you please fix it, or at give me something that is similar that can actually works.

function clicked(player, dialogChoice)
print("Talked")
print(player)
print(dialogChoice)
if dialogChoice.Name == "Ticket" then
print("Player gives Ticket")
g = game:GetService("InsertService"):LoadAsset(213984396) --Model ID number
g.Parent = player.Backpack 
g:MakeJoints() -- Capitalize just incase. 
g:MoveTo(player.Character:WaitForChild("Head").Position)
else
print(dialogChoice)
end
end


script.Parent.DialogChoiceSelected:connect(clicked)



0
It doesn't really make sense to use the InsertService for this. Why can't you just include the tool in the place, e.g., in ReplicatedStorage? BlueTaslem 18071 — 10y
0
I just found this, Plus I don't script much since I am not good at it. So what do I do to put it in the ReplicatedStorage User#5689 -1 — 10y
0
The tool that this script would insert. Goulstem 8144 — 10y

1 answer

Log in to vote
-1
Answered by 10 years ago

Instead of using the InsertService, you could just parent the tool under ReplicatedStorage, and then clone it to the Player.

script.Parent.DialogChoiceSelected:connect(function(player, dialogChoice)
    print("Talked")
    print player
    print dialogChoice
    if dialogChoice.Name == "Ticket" then
        print("Player gives Ticket")
        g = game.ReplicatedStorage:FindFirstChild("MODEL")  -- Replace MODEL with the name of your model in ReplicatedStorage
        g:Clone().Parent = player.Backpack
    else print("Failed")
    end
end)

You shouldn't be asking for code in this website. Instead, you should post the code and try to tell the community what error(s) you see or get.

0
Yes sir. I am sorry. User#5689 -1 — 10y
Ad

Answer this question