Topic is pretty self-explanatory. If you can help, thanks!
Do search the Forum first before creating your Topic
Thanks! From that I found this:
local rayDirection = game.Lighting:GetSunDirection()
local char = game.Players.LocalPlayer.Character
local RAY_LENGTH = 30
game:GetService(“RunService”):BindToRenderStep(“SunService”,Enum.RenderPriority.Camera.Value + 1,function()
local ray = Ray.new(char.HumanoidRootPart.Position,rayDirection * RAY_LENGTH)
local partFound = workspace:FindPartOnRay(ray,char)
if partFound then
print(“Found something blocking sun:”,partFound)
else
print(“No shadow”)
end
end)
game.Lighting:GetPropertyChangedSignal(“TimeOfDay”):Connect(function()
rayDirection = game.Lighting:GetSunDirection()
end)
@JackscarIitt Are you there? I customized this script to make an AI burn in the sunlight, but it does not work. No errors in output.
local rayDirection = game.Lighting:GetSunDirection()
local char = script.Parent
local RAY_LENGTH = 30
game:GetService(“RunService”):BindToRenderStep(“SunService”,Enum.RenderPriority.Camera.Value + 1,function()
local ray = Ray.new(char.HumanoidRootPart.Position,rayDirection * RAY_LENGTH)
local partFound = workspace:FindPartOnRay(ray,char)
if not partFound then
script.Parent:BreakJoints()
end
end)
game.Lighting:GetPropertyChangedSignal(“TimeOfDay”):Connect(function()
rayDirection = game.Lighting:GetSunDirection()
end)
Could you try this debugging script? Also make sure the script is inside either the workspace
or ServerScriptService
local rayDirection = game.Lighting:GetSunDirection()
local char = script.Parent
local RAY_LENGTH = 30
game:GetService("RunService"):BindToRenderStep("SunService",Enum.RenderPriority.Camera.Value + 1,function()
print("Running")
local ray = Ray.new(char.HumanoidRootPart.Position,rayDirection * RAY_LENGTH)
local partFound = workspace:FindPartOnRay(ray,char)
if not partFound then
print("Found part")
char:BreakJoints()
else
print("Not found part")
end
end)
All right I will try this in a bit and tell you how it goes.
Edit: Oddly, it is now working (aside from in it’s first life before any respawns, which I can easily fix by killing it once). Thanks!
Can you check what the Output prints each time you head somewhere?
Yes, I did. One the times that the script does not work, it prints nothing. On the times the script does work, however, it prints accordingly and properly.
Pinging me won’t really do anything unless if I’m actually available at this point of time
So apparently I just realized that you can only use BindToRenderStep
on the Client, and not the Server whoops
If you want a NPC/AI, use Heartbeat
on the Server I believe:
local rayDirection = game.Lighting:GetSunDirection()
local char = script.Parent
local RAY_LENGTH = 30
print(rayDirection)
game:GetService("RunService").Heartbeat:Connect(function()
print("Running")
local ray = Ray.new(char.HumanoidRootPart.Position,rayDirection * RAY_LENGTH)
local partFound = workspace:FindPartOnRay(ray,char)
if not partFound then
print("Found part")
char:BreakJoints()
else
print("Not found part")
end
end)
Thank you. Heartbeat works!