Passing a variable into a local script with a remote event

its on a click detector thats the thing, i dont really use remote events that much so idk

i see, maybe click it a bit later when everything lloads- WAIT WAIT

by doing what i said here, converting it to text based on the choice, either on the client or server

omg i just remembered localscripts cannot access server containers like serverscriptservice

thats why it appears as nil on the client bcz they cant access it, put it in repstorage or something

local serverstorage = game:GetService("ServerStorage")
local DisastersFolder = serverstorage:WaitForChild("Disasters")
local Disasters = DisastersFolder:GetChildren()
local button = script.Parent
local DisastersInProgress = workspace.Map.DisastersInProgress
local clickdec = script.Parent.ClickDetector
local db = false

clickdec.MouseClick:Connect(function(plr)
	if db == false then
		local count = #Disasters
		db = true
		local choiceindex = math.random(1, count)
		local choice = Disasters[choiceindex]
		game:GetService("ReplicatedStorage").DisasterGUI:FireAllClients(choice.Name)
		task.wait(5)
		choice.Parent = DisastersInProgress
		task.wait(10)
		choice.Parent = serverstorage
		db = false
	end
end)
local player = game.Players.LocalPlayer

local repstorage = game:GetService("ReplicatedStorage")
local StarterGui = player.PlayerGui
local Text = StarterGui.TextGui.DisasterText
local DisasterGui = repstorage.DisasterGUI

DisasterGui.OnClientEvent:Connect(function(choice)
	print(choice)
	Text.Text = "Chosen Disaster:"..choice.."."
end)```

could i do it like this

clickdec.MouseClick:Connect(function(plr)
if db == false then
local count = #Disasters
db = true
local choiceindex = math.random(1, count)
local choice = Disasters[choiceindex]
local c = nil
if choiceindex == 1 then
c = “Laser”
end
print(choice)
game:GetService(“ReplicatedStorage”).DisasterGUI:FireAllClients(c)
task.wait(5)
choice.Parent = DisastersInProgress
task.wait(10)
choice.Parent = serverstorage
db = false
end
end)

yeah sure just make sure evertyhing in repstorage

yes, that should work

charsssssssss

yes that could work, i think that we just overlooked that

taner30s solution did it, thanks everyone for the support

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.