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

value not change value when it says workspace.buildgui.value = 1?

Asked by 5 years ago

e hehe what so, i make a build gui and you go up to a noob to open it because he is shop and i put code in there for him to when touched change a value to 1. he is running the statement (because i threw a print in there and tested it.) but, he does not change the value. waht is going on? here is me code:

local debounce = false

function onHit(hit)
    local human = hit.Parent:findFirstChild("Humanoid")
    if (human ~= nil) and debounce == false then

                debounce = true
                if game.Workspace.turtorailno.Value == 5 then

                workspace.talking.Value = 1
                workspace.talktext.Value = "hi there! im bibby the builder. i can build anything you want if you have the items to build it."
                workspace.talkguy.Value = "billy"
                workspace.choice1.Value = "can you help us?"
                workspace.choice2.Value = "build a mansion."
                workspace.return1.Value = "okay dokay!"
                workspace.return2.Value = "NO."
                end
                     if game.Workspace.turtorailno.Value == 7 then

                workspace.talking.Value = 1
                workspace.talktext.Value = "i see you have some wood"
                workspace.talkguy.Value = "billy"
                workspace.choice1.Value = "yeah. can you build a hut for us?"
                workspace.choice2.Value = "now, build a mansion."
                workspace.return1.Value = "okay!"
                workspace.return2.Value = "maybye... not."
                end
                 if game.Workspace.turtorailno.Value == 9 then

                workspace.talking.Value = 1
                workspace.talktext.Value = "done!"
                workspace.talkguy.Value = "billy"
                workspace.choice1.Value = "hut... thats not that good."
                workspace.choice2.Value = "ok!"
                workspace.return1.Value = "i only had a few planks of wood."
                workspace.return2.Value = "i know right?"
                end
                if game.Workspace.tutorail.Value == 0 then
print("what")
workspace.buildgui.Value = 1
end



                debounce = false
    end
end

script.Parent.Touched:connect(onHit)
0
help me codingMASTER398 52 — 5y

1 answer

Log in to vote
0
Answered by
B_rnz 171
5 years ago

Woah first off, I'd use tables to make the scripts less 'messy.' I'll provide an example:

local Values = {
    ['TalkingValue'] = 1,
    ['TalkText'] = "hi there! im bibby the builder. i can build anything you want if you have the items to build it.",
    ['TalkGuyValue'] = "billy",
    ['Choice1'] = "can you help us?",
    ['Choice2'] = "build a mansion.",
    ['Return1'] = "okay dokay!",
    ['Return2'] = "NO."
}

Then you would assign these tables values by:

local debounce = false

function onHit(hit)
    local human = hit.Parent:findFirstChild("Humanoid")
    if (human ~= nil) and debounce == false then

                debounce = true
                if game.Workspace.turtorailno.Value == 5 then

                    workspace.talking.Value = Values['TalkingValue']
                    workspace.talktext.Value = Values['TalkText']
                    workspace.talkguy.Value = " Values['TalkGuyValue']
                    workspace.choice1.Value = Values['Choice1']
                    workspace.choice2.Value =  Values['Choice2']
                    workspace.return1.Value =  Values['Return1']
                    workspace.return2.Value =  Values['Return2']
                end
                debounce = false
    end
end

script.Parent.Touched:connect(onHit)

Second off, you're not adding the value, you're setting it (which cant possibly be done..) So you would correct it by doing:

if game.Workspace.tutorail.Value == 0 then
    workspace.buildgui.Value = workspace.buildgui.Value + 1
end

Hopefully this works! I had to rush because im doing something and this would be neater..

0
thanks, and no thanks. i will try to do the last thing, but i cant be bothered doing the rest. codingMASTER398 52 — 5y
0
wait. i cant do that because of various reasons. the script of the shop checks if the value is 1. if i do this, then, it will go 2, 3, 4 ,5, ect and the other script does not know that. codingMASTER398 52 — 5y
Ad

Answer this question