Hello all! I am in an urgent issue, and haven't been able to fix it! I've read some on the DevForum, and as well as on the developer wiki, but I cannot seem to understand how to do this, or what to do!
I've made various attempts, my latest will be posted below, but essentially what I am trying to accomplish is that when a player touches a brick, that the brick takes an item(if in their inventory), and gives them a specific amount of Gold for that item.
NOTE: This is a CUSTOM INVENTORY! It is located in the PlayerGui so, it's needed to call the playergui, as well, as find the weapon, and if the weapon is there, remove it, and give the Gold As well, this is in a ServerScript located INSIDE the part.
Here's my code, any and all help is appreciated! --
local player = game.Players.LocalPlayer
local char = player.Character
local wepon = player.char.PlayerGui.Arsenal.Backpack:WaitForChild("WoodenSword")
local gold = game.Players.LocalPlayer.leaderstats.Gold
script.Parent.Touched:Connect(function(touch)
if touch then
wepon:Destroy()
gold.Value = gold.Value+100
end
end)

5 comments
Kinda hard to sit down and walk you through every part of this but here is a useful piece ... look into using modules to store the values of all your weapons instead of writing out their value in your scripts.
no do not do this, if you follow what this guy says then that can be exploited since local scripts can edit the text inside a module script. this means that exploiters can change the value of those things
Wasn't planning on doing that I know they can be edited via exploit^
would not have suggested you use a local script to access a module. If I every do it, I send a request to the server which then accesses the module .
^How would I go around putting this in a script?