#Fire Client not working.

1 messages · Page 1 of 1 (latest)

flint jolt
#

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)
ember gazelle
#

ill try to help but am not reading all that just saying

#

so

#

show localscript

#

and does it print test?

flint jolt
#

client script:

--All GUI buttons are controlled here

local PlayerService = game:GetService("Players")
local LocalPlayer = PlayerService.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local GameGUI = LocalPlayer.PlayerGui:WaitForChild("GameGUI")

HRP.Anchored = true --Player Can't move until world is generated
local LoadWorld = script.Parent
local WaterToggle = script.Parent.Parent["Water Toggle"]
local Seed = script.Parent.Parent.Seed
local GenFlat = script.Parent.Parent["Generation Flatness"]
local WorldSize = script.Parent.Parent["World Size"]
local GUI = script.Parent.Parent.Parent

local LoadWorldEvent = game:GetService("ReplicatedStorage"):WaitForChild("Load World")
local WorldLoadedEvent = game:GetService("ReplicatedStorage"):WaitForChild("World Loaded")
local WaterEnabled = true


WaterToggle.MouseButton1Down:Connect(function()
    WaterEnabled = not WaterEnabled

    if WaterEnabled then
        WaterToggle.BackgroundColor3 = Color3.new(0, 1, 0)

    else
        WaterToggle.BackgroundColor3 = Color3.new(1, 0, 0)

    end
end)

LoadWorld.MouseButton1Down:Connect(function()
    GUI:Destroy()
    LoadWorldEvent:FireServer(LocalPlayer, WaterEnabled, Seed.Text, GenFlat.Text, WorldSize.Text) --Starts the generation
    
    
end)

WorldLoadedEvent.OnClientEvent:Connect(function(Seed, SpawnPoint)
    print('    H    IIII')
    GameGUI.Seed.Text = Seed
    HRP.CFrame = SpawnPoint
    
end)
ember gazelle
#

bud?

#

am i slow

#

or u done

#

.MouseButton1Down

#

on

#

wait

#

am slow i tink

flint jolt
#

I used random print words just to debug, it prints Text and Working

ember gazelle
#

ok nvm i saw wrong

#

mb lol

ember gazelle
#

even tho it prints

flint jolt
ember gazelle
#

so prints test but doesnt print H IIII

flint jolt
ember gazelle
#

am either missing smth

#

or u sending player

#

thro remote

#

theres no need for that

#

player is always the first argument sent

#

if fire server ofc

#

so your arguments are 1 off

#

on server

#

swapped places with eachother

flint jolt
ember gazelle
#

if

#

u

#

fire server

#

first argument with .OnClientEvent is ALWAYS player

#

thats by roblox

#

so if u do fireserver(arg1,arg2,arg3)
Server recieves player,arg1,arg2,arg3

flint jolt
#

Still dose not work

#

nop errors

ember gazelle
#

still prints Test?

flint jolt
#

test

#

yes

ember gazelle
#

extremly weird

#

u sure u aint getting infinite yield?

flint jolt
#

Wait, it cant be an infinite yield because if Test is called then WorldLoadedEvent:FireClient(Player, Seed, SpawnPoint) should be called.

ember gazelle
#

oh ye righttttt

#

where is the localscript located?

flint jolt
flint jolt
#

Yep thats the issue