I cant get the Server to send a Event trigger to the Client for some reason, i put it into the part i want it to be in, i did everything i could but it didnt work, is there anything i could do to fix it?
Server Script >
–[[ Player along the part. ]]–
local players = game.Players
local part = script.Parent.Position
–[[ Debug to play only once. ]]–
local Stop = false
–[[ Giving maxDistance a value(how close the player has to be before the scipt triggers) ]]–
local maxDistance = 100
–[[ Constantly check to see if the player is close to the part. ]]–
while wait() do
if Stop == false then
for i, player in players:GetChildren() do
if player.Character then
if player:DistanceFromCharacter(part) < maxDistance then
–[[ Debuging ]]–
print(“Player is in border”)
--[[ We comunicate with the players "view" to Raycast ]]--
local RayEvent = game.ReplicatedStorage:WaitForChild("RayEvent1")
if RayEvent then
RayEvent:FireClient(player)
else
warn("No RayCast event.")
end
--[[ Makes the script play only once. ]]--
Stop = true
--[[ More debuging ]]--
wait(0)
end
end
end
end
end
Client Script >
–[[ Get the Event from ReplicatedStorage. ]]–
local rayEvent = game.ReplicatedStorage:WaitForChild(“RayEvent1”)
–[[-]]–
rayEvent.OnClientEvent:Connect(function()
local partPosition = game.Workspace:WaitForChild(“MonstSpawner”)
local rayOrigin = partPosition + Vector3.new(0, 5, 0)
local direction = Vector3.new(0, -100, 0)
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {script.Parent}
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.IgnoreWater = true
local raycastResult = workspace:Raycast(rayOrigin, direction, rayParams)
--[[ Checks to see if the raycastResult exists. ]]--
if raycastResult then
local resault = {
raycastResult.Instance,
raycastResult.Position,
raycastResult.Material,
raycastResult.Distance
}
--[[ Prints the result. ]]--
print(resault)
else
warn("No raycast result!")
end
end)