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

game cant recognise that the name == the Equipped value... Why?

Asked by 6 years ago

i'm making a Gui shop and i'm trying to find an accessory inside the players character that equals the Equipped Value and Deletes it.

the script is a global script in ServerScriptService.

iv'e looked at it for a long time and can't seem to find the issue.

01game.ReplicatedStorage:WaitForChild("CreateTransactionBag").OnServerInvoke = function(player,Item) --this is the triggering function when the players clicked the buy button
02 
03--CreatTransactionBag is a RemoteFunction
04    local gold = game.Players:FindFirstChild(player.Name).leaderstats.Gold
05    local cost = game.ServerStorage.ShopFolder.BagShop.ItemModels[Item].Information.Cost
06    local Class = game.ServerStorage.ShopFolder.BagShop.ItemModels[Item].Information.Class
07 
08 
09    print(gold.Value)
10    print(cost.Value)
11 
12    if gold.Value >= cost.Value and not game.ServerStorage.PlayerStuff[player.Name].Bags:FindFirstChild(Item) then
13print ("Test1")--prints in testing
14        gold.Value = gold.Value-cost.Value
15 
View all 23 lines...

2 answers

Log in to vote
0
Answered by
popeeyy 493 Moderation Voter
6 years ago
Edited 6 years ago

You should use Console to examine the errors. You didn't have enough ends in your code to close the if statements. This could've simply been a syntax error.

Here is the fixed code I came up with, let me know if there are any issues.

01game.ReplicatedStorage:WaitForChild("CreateTransactionBag").OnServerInvoke = function(player,Item) --this is the triggering function when the players clicked the buy button
02    --CreatTransactionBag is a RemoteFunction
03    local gold = game.Players:FindFirstChild(player.Name).leaderstats.Gold
04    local cost = game.ServerStorage.ShopFolder.BagShop.ItemModels[Item].Information.Cost
05    local Class = game.ServerStorage.ShopFolder.BagShop.ItemModels[Item].Information.Class
06 
07 
08    print(gold.Value)
09    print(cost.Value)
10 
11    if gold.Value >= cost.Value and not game.ServerStorage.PlayerStuff[player.Name].Bags:FindFirstChild(Item) then
12        print("Test1") --prints in testing
13        gold.Value = gold.Value - cost.Value
14 
15        print(player.HidenStats.EquipedTool.Value) --this is the Equipped Value's location
View all 24 lines...

EDIT:

On the lines of Destroying the current equipped tool, you can destroy the tool inside of the value, no need to search for it.

01game.ReplicatedStorage:WaitForChild("CreateTransactionBag").OnServerInvoke = function(player,Item) --this is the triggering function when the players clicked the buy button
02    --CreatTransactionBag is a RemoteFunction
03    local gold = game.Players:FindFirstChild(player.Name).leaderstats.Gold
04    local cost = game.ServerStorage.ShopFolder.BagShop.ItemModels[Item].Information.Cost
05    local Class = game.ServerStorage.ShopFolder.BagShop.ItemModels[Item].Information.Class
06 
07 
08    print(gold.Value)
09    print(cost.Value)
10 
11    if gold.Value >= cost.Value and not game.ServerStorage.PlayerStuff[player.Name].Bags:FindFirstChild(Item) then
12        print("Test1") --prints in testing
13        gold.Value = gold.Value - cost.Value
14 
15        print(player.HidenStats.EquipedTool.Value) --this is the Equipped Value's location
16        player.HidenStats.EquipedTool.Value:Destroy()
17    end
18end
0
do you mean the output cause there are no errors Nooberton_1 9 — 6y
0
What type of Value is EquipedTool? popeeyy 493 — 6y
0
String Nooberton_1 9 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

I found myself a solution!

01game.ReplicatedStorage:WaitForChild("CreateTransactionBag").OnServerInvoke = function(player,Item)
02 
03    local gold = game.Players:FindFirstChild(player.Name).leaderstats.Gold
04    local cost = game.ServerStorage.ShopFolder.BagShop.ItemModels[Item].Information.Cost
05    local Class = game.ServerStorage.ShopFolder.BagShop.ItemModels[Item].Information.Class
06 
07 
08    print(gold.Value)
09    print(cost.Value)
10 
11    if gold.Value >= cost.Value and not game.ServerStorage.PlayerStuff[player.Name].Bags:FindFirstChild(Item) then
12print ("Test1")
13        gold.Value = gold.Value-cost.Value
14 
15        if player.Character:FindFirstChild(player.HidenStats.EquipedBag.Value)then
16            player.Character:FindFirstChild(player.HidenStats.EquipedBag.Value):Destroy()
17        end
18    end
19end
0
so i guess the question is anserd Nooberton_1 9 — 6y

Answer this question