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
01enabled = true
02 
03function onTouch()
04    if enabled == true then
05        enabled = false
06        shell = game.ReplicatedStorage.Shell:Clone()
07        shell.Parent = script.Parent.Parent
08        shell.CFrame = script.Parent.Parent.Spawn1.CFrame
09        shell2 = shell:Clone()
10        shell2.Parent = script.Parent.Parent
11        shell2.CFrame = script.Parent.Parent.Spawn2.CFrame
12        wait(0.5)
13        shell3 = shell2:Clone()
14        shell3.Parent = script.Parent.Parent
15        shell3.CFrame = script.Parent.Parent.Spawn1.CFrame
View all 57 lines...

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:

1--15:34:33.428 - Value is not a valid member of UnionOperation
2--15:34:33.429 - Script 'Workspace.Shell Complex.Sensor.Script', Line 21
3--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