Hey devs, I am wondering if anyone can help me sort this mess out. The game I am working on allows for mystery boxes around the map that when touched, they set their own “Active” value to false and go transparent. On the flip side, the vehicle the player drives has a mystery box item system that calls certain events on a random basis when the item box is touched.
My issue is, almost 2/3 of the item boxes I have on the map work. They are doing their job, but for some reason the touch event in the vehicle only detects the values of like 3 out of 10 boxes.
basepart.Touched:Connect(function(other)
if other.Name == ("MysteryBox") and driverSeat.abilityget.Value == false then
print("Passed Initial Check")
local boxval = other:findFirstChild("Active")
if boxval.Value == true then
print("Boxval Passed")
driverSeat.abilityget.Value = true
sounds["Space Chimes"]:Play()
fx.GeneralAbilities.Stars.Enabled = true
task.wait(4)
sounds["Enemy Gadget - Brawl Stars SFX"]:Play()
driverSeat.abilityget.Value = true
task.wait()
fx.GeneralAbilities.Stars.Enabled = false
local number = math.random(1,7)
task.wait()
abilnumber.Value = number
if number == 1 then
abilityPrompt.ObjectText = "You got: Overload Ability!"
elseif number == 2 then
abilityPrompt.ObjectText = "You got: Damage Ring Ability!"
elseif number == 3 then
abilityPrompt.ObjectText = "You got: Fire Ball Ability!"
elseif number == 4 then
abilityPrompt.ObjectText = "You got: Ice Cube Ability!"
elseif number == 5 then
abilityPrompt.ObjectText = "You got: SUPER Ability!"
elseif number == 6 then
abilityPrompt.ObjectText = "You got: Blizzard Ability!"
elseif number == 7 then
abilityPrompt.ObjectText = "You got: Bomb Ability!"
end
abilityPrompt.Enabled = true
else
print("Boxval Failed")
end
end
end)
thanks ill look into the getpartsinpart, and yeah I have a playable version, it’s just the updates im doing now require more script changes that I was not prepared for lol
You can find it here if you’re interested: Ball Wars - Roblox
the item boxes are in based on their outter box so I have that going for me lol, I am just worried if the boxes are in a folder in the map, when the map changes there will be different boxes .
the mystery boxes are comprised of 4 parts, an outer box, inner box, the ? mesh and an invisible .1x.1x.1 part that is hinged to the rest to make it spin. the outer box is what is being called for touch.
And unrelated; but how did you make that box with only the outline and no fill? I’ve wondered on how to do that, but I have only managed to do it with multiple parts, which would be very unoptimized.
However, even still. How I have it now the script for the touch does return that it has touched the cubes. It just isn’t finding that boolean value within the cubes. Would GetPartsinParts really fix that?
If anyone knows how I could apply get parts in parts in this script I am all ears. I tried looking it up and it seems simple but it doesn’t seem like it’ll do what I need it to do.
Upon a lot of web searching and trial and error, I have found a solution to my issue! Hopefully to anyone who stumbles upon this will find it very helpful.
To find a boolValue from a part that is being Touched(), this is what I did:
basepart.Touched:Connect(function(other)
local touchedBoolValue = other:FindFirstChild("Active")
if touchedBoolValue then
local boolValueState = touchedBoolValue.Value
if other.Name == ("MysteryBox") and boolValueState == true and driverSeat.abilityget.Value == false then