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

My shop script doesn't work and there's no error showing. Anyone know how to fix this?

Asked by 4 years ago
local Dialog = script.Parent

Dialog.DialogChoiceSelected:Connect(function(player, choice)

    local stats = player:FindFirstChild("leaderstats")
    if not stats then return end

    local Stomps = stats.Stomps
    if not Stomps then return end

    if choice == script.Parent.Shop.TeddyChoice then
        if Stomps.Value >= 5 then
            local TeddyClone = game.ReplicatedStorage.Teddy:Clone()
            TeddyClone.Parent = player.Backpack
            Stomps.Value = Stomps.Value - 5
            print("Purchase Success")
        end
    end

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

0
Did you use a Server or Local Script? youtubemasterWOW 2741 — 4y
0
This is a server script EmmettNRedblueYT 22 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

local Dialog = script.Parent
local Player = game:GetService("Players")LocalPlayer

Dialog.DialogChoiceSelected:Connect(function(player, choice)

    local stats = player:FindFirstChild("leaderstats")
    if not stats then return end

    local Stomps = stats.Stomps
    if not Stomps then return end

    if choice == script.Parent.Shop.TeddyChoice then
        if Stomps.Value >= 5 then
            local TeddyClone = game.ServerStorage.Teddy:Clone()
            game.ServerStorage.Teddy:Clone(Player.Backpack)
            Stomps.Value = Stomps.Value - 5
            print("Purchase Success")
        end
    end

end)

Please accept answer if it helps!

0
You can't access server storage or server scripts service from the LocalScript state thatwalmartman 404 — 4y
0
Odd. Ive had no problem doing that. TotalElevation 45 — 4y
Ad

Answer this question