01 | local Dialog = script.Parent |
02 |
03 | Dialog.DialogChoiceSelected:Connect( function (player, choice) |
04 |
05 | local stats = player:FindFirstChild( "leaderstats" ) |
06 | if not stats then return end |
07 |
08 | local Stomps = stats.Stomps |
09 | if not Stomps then return end |
10 |
11 | if choice = = script.Parent.Shop.TeddyChoice then |
12 | if Stomps.Value > = 5 then |
13 | local TeddyClone = game.ReplicatedStorage.Teddy:Clone() |
14 | TeddyClone.Parent = player.Backpack |
15 | Stomps.Value = Stomps.Value - 5 |
16 | print ( "Purchase Success" ) |
17 | end |
18 | end |
19 |
20 | end ) |
This is my code, I was creating a thing where if you select a dialog choice for one of the characters in my game, you get a tool in your backpack if you pay 5 "Stomps" from the leader stats.
But nothing happens, the tool isn't in my backpack, there is no error in the output, it doesn't print my message, I've tried to change a lot of things but nothing new in the output and nothing worked. I hope somebody can help me figure this out! Thank you
Well to me it seems that the issue is because the tool is in ReplicatedStorage. Try putting the tool into ServerStorage. Well, at least I'm assuming its a tool.
I have modded the script accordingly, modding the "tool giving"(?) part of the script and added a variable.
01 | local Dialog = script.Parent |
02 | local Player = game:GetService( "Players" )LocalPlayer |
03 |
04 | Dialog.DialogChoiceSelected:Connect( function (player, choice) |
05 |
06 | local stats = player:FindFirstChild( "leaderstats" ) |
07 | if not stats then return end |
08 |
09 | local Stomps = stats.Stomps |
10 | if not Stomps then return end |
11 |
12 | if choice = = script.Parent.Shop.TeddyChoice then |
13 | if Stomps.Value > = 5 then |
14 | local TeddyClone = game.ServerStorage.Teddy:Clone() |
15 | game.ServerStorage.Teddy:Clone(Player.Backpack) |
Please accept answer if it helps!