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

Output makes no sense?

Asked by 10 years ago
enabled = true

function onTouch()
    if enabled == true then
        enabled = false
        shell = game.ReplicatedStorage.Shell:Clone()
        shell.Parent = script.Parent.Parent
        shell.CFrame = script.Parent.Parent.Spawn1.CFrame
        shell2 = shell:Clone()
        shell2.Parent = script.Parent.Parent
        shell2.CFrame = script.Parent.Parent.Spawn2.CFrame
        wait(0.5)
        shell3 = shell2:Clone()
        shell3.Parent = script.Parent.Parent
        shell3.CFrame = script.Parent.Parent.Spawn1.CFrame
        shell4 = shell3:Clone()
        shell4.Parent = script.Parent.Parent
        shell4.CFrame = script.Parent.Parent.Spawn2.CFrame
        wait(1.5)
        while wait() do
            if shell.Value.Value == 25 then
                shell:Destroy()
            break
            elseif shell.Value.Value == 0 then
                shell:Destroy()
            end
        end
        while wait() do
            if shell2.Value.Value == 25 then
                shell2:Destroy()
            break
            elseif shell2.Value.Value == 0 then
                shell2:Destroy()
            end
        end
        wait(0.5)
        while wait() do
            if shell3.Value.Value == 25 then
                shell3:Destroy()
            break
            elseif shell3.Value.Value == 0 then
                shell3:Destroy()
            end
        end
        while wait() do
            if shell4.Value.Value == 25 then
                shell4:Destroy()
            break
            elseif shell4.Value.Value == 0 then
                shell4:Destroy()
            end
        end
        enabled = true
    end
end

script.Parent.Touched:connect(onTouch)

This script causes shells to roll down a hill and disappear after a set time. If a shell hits someone, the script will wait for the shell's script to execute before destroying it. The shell itself gradually decreases the player's health by 25, and the IntValue (named Value) in the shells keep track of when the player's health is successfully drained. The Value should hit 25, signalling the script that the script is done and that it's okay to destroy the shell. However, when the script is triggered, this shows up in the output:

--15:34:33.428 - Value is not a valid member of UnionOperation
--15:34:33.429 - Script 'Workspace.Shell Complex.Sensor.Script', Line 21
--15:34:33.429 - Stack End

What?! I checked the clones that the script spawns, and they do indeed have Values in them. Is the problem cause by the fact that the shells are unions? What's going on? The shells are named Shell, not UnionOperation.

2 answers

Log in to vote
0
Answered by 10 years ago

Is the value named 'Value'? Try changing it to 'BarrelValue' or something of that sort.

0
I'm afraid this doesn't work. IcyArticunoX 355 — 10y
0
Try shell:FindFirstChild('Value') killerkill29 35 — 10y
Ad
Log in to vote
0
Answered by
Tkdriverx 514 Moderation Voter
10 years ago

What is happening is that Lua thinks that shell.Value.Value is looking for a PROPERTY called Value. To fix this, rename it to something besides "Value" or do shell:findFirstChild("Value").Value

Answer this question