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

What's wrong with my script? Please help if possible, I'm a begginer

Asked by
Fako16 13
5 years ago
local name = script.Parent.Parent.ItemName
local resources = script.Parent.Parent.Resources
local itemgiven = script.Parent.Parent.ItemGiven
local wood = game.Players.LocalPlayer.rStats.WoodStat
local stone = game.Players.LocalPlayer.rStats.StoneStat
local cloth = game.Players.LocalPlayer.rStats.ClothStat

function craft()
--- BOW
    if name.Text == "Bow" then
        if wood.Value >= 50 then
            wood.Value = wood.Value - 50
            itemgiven.Text = "Bow given, check your inventory."
        else
            if wood.Value < 50 then
                itemgiven.Text = "Bow not given, not enough wood."
            end
        end
--- PLEASE SELECT A ITEM
    elseif name.Text == "Select a Item" then
        print("Please Select a Item")
--- STONE HATCHET
    elseif name.Text == "Stone Hatchet" then
        if wood.Value >= 10 then
            if stone.Value >= 40 then
                wood.Value = wood.Value - 10
                stone.Value = stone.Value - 40
                itemgiven.Text = "Stone Hatchet given, check your inventory."
            end
        elseif wood.Value < 10 and stone.Value < 40 then
            itemgiven.Text = "Stone Hatchet not given, not enough wood and stone."
        elseif wood.Value < 10 and stone.Value >= 40 then
            itemgiven.Text = "Stone Hatchet not given, not enough wood."
        elseif wood.Value >= 10 and stone.Value < 40 then
            itemgiven.Text = "Stone Hatchet not given, not enough stone."   
--- WOOD HATCHET
    elseif name.Text == "Wood Hatchet" then
        if wood.Value >= 30 then
            if stone.Value >= 10 then
                wood.Value = wood.Value - 30
                stone.Value = stone.Value - 10
                print("Wood Hatchet Given")
            end
        end
    end
end
end

script.Parent.Activated:Connect(function()
    craft()
end)

Whats wrong with this script? Please tell me, also if you saw my last question and are annoyed that I'm asking questions this fast, I'm sorry, but I'm a begginer and I want to learn ASAP.

0
Can you please tell me what this script does and what is being said in your output. If you could tell me where in your script the error is, or what the error is, that would make it convenient for me to assist to you. Vmena 87 — 5y
0
@Vmena No error is popping out, this script is used for the Craft button of a Crafting GUI,my problem is that after running it once and for example getting wood, the script wouldn't run again. Fako16 13 — 5y

1 answer

Log in to vote
-1
Answered by
herrtt 387 Moderation Voter
5 years ago

I think its because you either use a localscript, and localscript cant change anything on the server (without help of remotes) or you use a regular script, and regular scripts can't use LocalPlayer. Since you are new into remotes I suggest looking into some of it in the API. Some links you may get need of: https://developer.roblox.com/articles/Remote-Functions-and-Events https://developer.roblox.com/api-reference/function/RemoteEvent/FireClient https://developer.roblox.com/api-reference/event/RemoteEvent/OnClientEvent

Hope this helped you a little bit :)

0
I'm not changing anything server-based and I'm not using a remote event, but thanks for the response :D Fako16 13 — 5y
0
Maybe using WaitForChild() could work a little bit. herrtt 387 — 5y
0
Nah, my issue is that the script doesn't want to run itself multiples times when it's requested to (when the player clicks the craft button) Fako16 13 — 5y
Ad

Answer this question