mds:DetectLightAtPoint(vec)
= mds.DetectLightAtPoint(mds, vec)
.
Use the dot or colon operator appropriately.
mds:DetectLightAtPoint(vec)
= mds.DetectLightAtPoint(mds, vec)
.
Use the dot or colon operator appropriately.
I don’t get what you mean or how I’m supposed to use this.
Also the module.DetectLightAtPoint
was taken from the module script so idk what i did wrong
It’s supposed to be module.DetectLightAtPoint
, not module:DetectLightAtPoint
.
well I didn’t write that
303030303030
Yes, you did:
Not the function, I meant when you call it.
well the creator did
3030303
Then I must be wrong. It’s probably a different issue.
I just switched the module.function to module:function and it now it doesn’t error, it just doesn’t work. It doesn’t detect any light, which is the entire point of this.
Thanks to @SubtotalAnt8185 I changed line 123 to
function module:DetectLightAtPoint(Point: Vector3)
but now it just doesn’t work. It doesn’t detect any lights at all.
oh i figured it out so apparently your module doesn’t support surface lights.
edit: aaaahhhh okay so I had a big part with a surface light on the bottom side, so I was in the light AND the shadow, and I guess it got confused and just went with me being in the shadow.
How do I use this and why is there no clear tut or this?
Do you think you could provide the snippet you used in order to turn the red parts green and vice versa? I am having quite a bit of trouble understanding how I’m supposed to go about changing something after it leaves the light. I’m attempting to make a UV flashlight out of this that would let people see blood and invisible ink but I’m just having a hard time wrapping my head around it lol.
It seems this project has been abandoned, seeing as OP refuses to elaborate more on how to use the module in a way that isn’t bugged.
I’ve been busy lately since I will go to university soon and I’m way to focused in my career building and school subjects that matter.
Last time that I’ve tested it appeared have no issues. Make sure to use the link if you are not using it already
I will check it out later this week when I have time
I understand you don’t have a lot of time, but I will post this here so I don’t forget later. We just want to know how you managed to make the part change colour when it went from light to dark in the video. The example code you provided just sends an error:
ReplicatedStorage.LightDetectionRevamp:84: attempt to perform arithmetic (add) on table and Vector3
KUW_Alt1 said that this problem was caused by using a surface lights, and they fixed it by using a different light. However, in my case, it just spits out this error all the time, regardless of what type of light is being used.
And yes, I am using the module from the link. The problem is that the setup is incredibly vague in this post, and we are just confused how we’re supposed to use this module. Like mugwomp41 said, we just need the snippet of code you used in the video. Thanks in advance.
noticed that some dudes were having some semi-recent problems with recreating the example in OP, so i made this quick rbxl in hopes of helping at least one or two of them out
examples.rbxl (55.9 KB)
don’t know if it’d be helpful but it’s worth a shot anyways
Thank you for this example however I do have a problem.
How would I have this system work with a table
I am trying to have every part in the workspace.Players:GetChildren()
work with the light system however it only works in the first part in the table. Not the rest
Full Code if you want to test it out:
local Players = game:GetService("Players")
local lightStuff = require(game.ReplicatedStorage.Modules.LightDetectionRevamp)
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
wait(1)
char.Parent = workspace.Players
local hitray = script.Light.HitRay:Clone()
local hitbox = script.Light.HitBox:Clone()
hitray.Parent = char:WaitForChild("HumanoidRootPart")
hitbox.Parent = char:WaitForChild("HumanoidRootPart")
for i,v in pairs(workspace.Players:GetChildren()) do
if v.Name ~= char.Name then
--local root = v.HumanoidRootPart
print(v)
while task.wait() do
local lightInfo = lightStuff.DetectLightAtPoint(v.Position)
local isInLight = lightInfo.InLight
v.Color = Color3.new(0,isInLight and 1 or 0,0)
end
end
end
end)
end)
i believe that this is an issue inside of the module that OP posted, but i found out what was causing it, so i made a quick workaround that solves it. here’s a quick explanation since its like 8:43 pm and i have to get ready for school tmrw:
basically, what’s happening in the function below is that it’s not returning the results that it’s supposed to be returning because of how table.remove()
works and how their checks are laid out.
local parts = {workspace.Part1, workspace.Part2, workspace.Part3} --// assume that these all either have CastShadow disabled or are transparent
local function CheckObfuscated(t)
for i,part : BasePart in t do
if part.CastShadow == false then
table.remove(t,i) --// removes an entry from the table using an index, but doesn't account for future indexes (the index would be off by one since an item was already removed)
end
if part.Transparency >= 0.5 then --// proceeds to run another check which removes another item from the table which also risks miscalculations
table.remove(t,i) --// does the same as the first check
end
end
return t
end
local partTable = CheckObfuscated(parts)
print(partTable) --// would print an inconsistent result since, in the CheckObfuscated function, it removed elements without accounting for the later elements that were shifted down to the empty space in the table
there are a few different ways of fixing this, but my personal solution was to make a function that guarantees that the unwanted parts are returned by the CheckObfuscated function while also continuing in the loop after one of the checks returned something. you could probably mess around and find your own solutions, though, so please try to look for something better than what i came up with lol. here’s an snippet of what im talking about so that u could get a proper idea of what i mean
local function RemoveIndexes(Table, Indexes)
local NewTable = {}
for Index, Value in pairs(Table) do
if not table.find(Indexes, Index) then
table.insert(NewTable, Value)
end
end
return NewTable
end
local function CheckObfuscated(t)
local remove = {}
for i,part:BasePart in pairs(t) do
if part.Transparency >= 0.5 then
table.insert(remove,i); continue
end
if part.CastShadow == false then
table.insert(remove,i); continue
end
end
return RemoveIndexes(t,remove)
end
I do understand the example code you made for me in the first half. However I am very stuck as to how I would do it myself I am still somewhat new to Roblox Lua.
The second half of your explanation seems very advanced for me.
CheckObfuscated() seems to create a empty table and fills it with elements from the table referenced after checking if part doesn’t cast shadows and transparency greater or equal to 0.5 and returns a table created by RemoveIndexes() which returns a table with the indexes from the old table
Yes I understand that part (First half of the example post)
The part where I have a problem is using that example to fix the current problem I have. I do not know how I would go about doing it as it seems very advanced to me even though I do understand the example.