Hello, I am trying to make a terrain generation game for fun I have a gui where you can set a number press a generate button that will connect to a remote event that will then enable the terrain generation the problem is I need to set a value in the rep storage to be the number of whatever the person inputted then the terrain gen script will see it but I cant do this in the local script because the terrain script is a server. So how can i parse through the integer to the event script that will enable the terrain?
heres my code for my my gui button
--//Locals
local event = game.ReplicatedStorage.Events.TerrainGeneration
local tweenService = game:GetService("TweenService")
local tweenInformation = TweenInfo.new(2)
local p = {TextTransparency = 1}
local d = false
--//Main
script.Parent.MouseButton1Up:Connect(function()
if not d then
d = true
script.Parent.c:Play()
local terrainGenerationNumber = tonumber(script.Parent.Parent.Number.Text)
if terrainGenerationNumber then
print("Success: Starting Terrain Generation")
event:FireServer()
script.Parent.Parent.Enabled = false
else
print("Error: Invalid Number")
script.Parent.Parent.invalid.TextTransparency = 0
wait(1)
local tween = tweenService:Create(script.Parent.Parent.invalid, tweenInformation, p)
tween:Play()
end
d= false
end
end)
heres my code for my event handler
--//Locals
local event = game.ReplicatedStorage.Events.TerrainGeneration
--//Main
game.Players.PlayerAdded:Connect(function(player)
event.OnServerEvent:Connect(function()
print("Running Terrain Generation")
local char = player.Character
local int = player.PlayerGui.TerrainGenerator.Number.Text
wait(1)
game.ReplicatedStorage.Values.BASE_HEIGHT.Value = int
char.HumanoidRootPart.Anchored = false
game.ServerScriptService.TerrainBlockGenerationChunkLoading.Disabled = false
end)
end)
if you can help me this would be amazing!