I am working on a system that takes a responce from a player and then communicates back to him. However WorldLoadedEvent:FireClient(Player, Seed, SpawnPoint) is not working, I get no errors.
Server Script:
local Terrain = workspace.Terrain
local LoadWorldEvent = game:GetService("ReplicatedStorage"):WaitForChild("Load World")
local WorldLoadedEvent = game:GetService("ReplicatedStorage"):WaitForChild("World Loaded")
local BlockScale = 4
local SpawnPoint
LoadWorldEvent.OnServerEvent:Connect(function(Player, WaterEnabled, Seed, TrrainThreshhold, WorldSize)
print("Working")
print(Player)
if not tonumber(Seed) or string.find(Seed, " ") or Seed == "" then --Checks if the inputed seed is valid
Seed = math.random(1, 10000)
end
Seed = math.abs(Seed) --Makes sure the seed is not a negitive value
if not tonumber(TrrainThreshhold) or string.find(TrrainThreshhold, " ") or TrrainThreshhold == "" then
TrrainThreshhold = 0.35 -- I am not going to rename this, don't feel like it.
end
TrrainThreshhold = tonumber(TrrainThreshhold)
if not tonumber(WorldSize) or string.find(WorldSize, " ") or WorldSize == "" then
WorldSize = 100
end
WorldSize = math.abs(WorldSize)
for z = 1, WorldSize do
for x = 1, WorldSize do
local NoiseTrrain = math.noise(x * 0.1, Seed, z * 0.1) * BlockScale --Prlin nose, my belovid.
NoiseTrrain = math.clamp(NoiseTrrain, -6, 6) --Clamps it
NoiseTrrain = (NoiseTrrain > TrrainThreshhold and TrrainThreshhold or NoiseTrrain) / TrrainThreshhold --A bunch of math and logic to make the trrain look natral
NoiseTrrain = (1 - NoiseTrrain)
local Vector3Position = Vector3.new(x * BlockScale, NoiseTrrain * BlockScale, z * BlockScale) --Creates positions
local Position = CFrame.new(Vector3Position)
local Size = Vector3.new(BlockScale, BlockScale, BlockScale) --Creates the size
local Material
if Position.Y >= 14 then --When Rock will generate
Material = Enum.Material.Rock
Terrain:FillBlock(Position - Vector3.new(0, BlockScale * 5, 0), Vector3.new(BlockScale, (BlockScale * 12) - NoiseTrrain, BlockScale), Enum.Material.Ground)
elseif Position.Y <= 0.5 and WaterEnabled then --When water will generate
Material = Enum.Material.Water
Terrain:FillBlock(Position - Vector3.new(0, BlockScale * 5, 0), Size, Enum.Material.Rock)
Terrain:FillBlock(Position - Vector3.new(0, BlockScale * 7, 0), Vector3.new(BlockScale, (BlockScale * 12) - NoiseTrrain, BlockScale), Enum.Material.Ground)
else
Material = Enum.Material.Grass --When grass.. will generate...
Terrain:FillBlock(Position - Vector3.new(0, BlockScale * 5, 0), Vector3.new(BlockScale, (BlockScale * 12) - NoiseTrrain, BlockScale), Enum.Material.Ground)
end
Terrain:FillBlock(Position, Size, Material) --Generate it
if x == 50 and z == 50 then
SpawnPoint = CFrame.new(Vector3Position + Vector3.new(0, 30, 0)) --Spawns player at the center of the map
end
end
end
print("Test")
WorldLoadedEvent:FireClient(Player, Seed, SpawnPoint)
end)