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)
script.Parent.Touched:Connect(function(touch) if touch.Parent:FindFirstChild("HumanoidRootPart") then--to see if its a player or not that touches it local player = game.Players:GetPlayerFromCharacter(touch.Parent)--self explainatory local gold = player.leaderstats.Gold local wepon = player.Character.PlayerGui.Arsenal.Backpack:FindFirstChild("WoodenSword") if wepon then--checks if the sword is there wepon:Destroy() gold.Value = gold.Value + 100 end end end)
make it a server script instead