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

"External values" refuse to change. How do I get this to work?

Asked by 9 years ago

I originally tried this with NumberValues, then I tried using StringValues. Unfortunately, neither of their value properties changed. This almost never happens when I am doing a small and simple script, and it's driving me crazy. What do I do to get them to change?

Boss = script.Parent
Fist1 = Boss.HandFighter1.Fist
FB1 = Fist1.BodyPosition.position
Hand1 = Boss.HandFighter1.OpenHand
HB1 = Hand1.BodyPosition.position
Fist2 = Boss.HandFighter2.Fist
FB2 = Fist2.BodyPosition.position
Hand2 = Boss.HandFighter2.OpenHand
HB2 = Hand2.BodyPosition.position
Attack1 = Fist1.Attack.Permission.Value
Attack2 = Fist2.Attack.Permission.Value
Attack3 = Hand1.Attack.Permission.Value
Attack4 = Hand2.Attack.Permission.Value
Disable1 = Boss.HandFighter1.Disable.Check.Value
Disable2 = Boss.HandFighter2.Disable.Check.Value

while true do
    wait(10)
    local num = math.random(1,3)
    print(num)
    if num == 1 then
        Attack1 = 1
        Attack2 = 1
        Disable1 = 1
        Disable2 = 1
        FB1 = game.Workspace.FistGuide1.Position
        FB2 = game.Workspace.FistGuide2.Position
        wait(4)
        if Attack1 == 1 then
            Attack1 = 0
        elseif Attack2 == 1 then
            Attack2 = 0
        elseif Attack1 == 1 and Attack2 == 1 then
            Attack1 = 0
            Attack2 = 0
        end
        FB1 = game.Workspace.HandGuide1.Fist.Position
        FB2 = game.Workspace.HandGuide2.Fist.Position
        Disable1 = 0
        Disable2 = 0
        elseif num == 2 then
            Attack3 = 1
            HB1 = game.Workspace.OpenHandSlapGuide1.Position
            wait(3)
            HB1 = game.Workspace.OpenHandSlapGuide2.Position
            wait(4)
            if Attack3 == 1 then
                Attack3 = 0
            end
            HB1 = game.Workspace.HandGuide1.OpenHand
        elseif num == 3 then
            Attack4 = 1
            HB2 = game.Workspace.OpenHandGuide2.Position
            wait(3)
            HB2 = game.Workspace.OpenHandGuide1.Position
            wait(4)
            if Attack4 == 1 then
                Attack4 = 0
            end
    end
end

The output doesn't say anything either. Would a more efficient script help, if this can get any simpler?

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

This is a really frequent mistake.

When you assign to Attack1 the first time, that just sets Attack1 = 0 (since the right side is just 0 (or whatever other number)). It doesn't "link" the Value object with the variable.

As a result, later changes to the variable Attack1 has nothing to do with the Value object itself.

The fix is to do something like this:

Attack1 = Fist1.Attack.Permission

.....

if num == 1 then
    Attack1.Value = 1

.....

As for simplifying the script, I'll be right back with that.


One small suggestion I have is to use BoolValues. You're using numbers, but you're only using 0 and 1, so you might as well use BoolValues.

If you could explain what the purpose of setting all of the values are (why do they need to be set? Why are you checking what you are checking?) I think could give good pointers of simplifying it.

0
Thank you very much. It's working much better, except two actions need fixing. The script is supposed to be for a test boss battle, as you might have guessed, featuring two hands. I change values in order to tell scripts in other parts to do things to help shorten this one script. "Permission", when set to 1, is supposed to allow one of the hands to deal damage when it touches someone, and reset t TwentyOneMau5e5 5 — 9y
Ad

Answer this question