Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can someone please fix this script?

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)



3 comments

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?

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

0

The tool that this script would insert.

1 answer

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.

1 comment

0

Yes sir. I am sorry.

This discussion is preserved as it was. New answers, comments, and votes are closed.