You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
So the gist is that i would like to know how to make a simple script in which exchanges a gear that the player has with another gear whenever they interact with a part. -
What is the issue? Include screenshots / videos if possible!
Ive been looking around online for any sort of tutorial on this matter but all ive found are videos that show something about there being dialogue before the part gives you the item, but thats uneeded for the thing im trying to achieve -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Ive looked around the toolbox and Dev Forum and the closest thing i can find to what im trying to achieve is this wonderful little script made by Aurarus which has the “exchange” part in it but also has connections to a dialogue prompt that doesnt exist it seems.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
So basically something like this but without the included dialogue connections.
--Made by Aurarus--
----------------------------------------------------------
local nameoftoolA = "GreenestHead" --Change "Key" to the name of the tool you want to exchange (Make sure it is in Lighting)
local nameoftoolB = "Reward" --Change this to the name of the tool you want to award. (Must be in Lighting as well)
local responseA = "*The king of greenia rewards you*" --This is what it'll say when the player is given the reward.
local responseB = "*The king recuires his head as proof*"
local responseC = "*The king wont reward you twice" --This is what it'll say if the player already has the reward.
local removetool = true --Change this to "false" if you don't want to take away the tool for the reward.
----------------------------------------------------------
function onSelect(plyr,Exchange)
if Exchange.Name == "Exchange" then
if plyr.Backpack:findFirstChild(tostring(nameoftoolA)) == nil then
Exchange.ResponseDialog = (tostring(responseB))
elseif plyr.Backpack:findFirstChild(tostring(nameoftoolB)) ~= nil then
Exchange.ResponseDialog = (tostring(responseC))
elseif plyr.Backpack:findFirstChild(tostring(nameoftoolA)) ~= nil then
if removetool == true then
plyr.Backpack:findFirstChild(tostring(nameoftoolA)):remove()
end
local rwrd = game.Lighting:findFirstChild(nameoftoolB):clone()
rwrd.Parent = plyr.Backpack
Exchange.ResponseDialog = (tostring(responseA))
end
end
end
script.Parent.Parent.DialogChoiceSelected:connect(onSelect)
I know this post is a bit of everything at once but thanks in advanced if anyone can help me out with my issue.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.