-
What do you want to achieve? A horror game where you activate generators. After activating these generators, a GUI will increase a number based on the amount of generators you activated.
-
What is the issue? I can’t get it to work. No matter what I try. Either it throws an error, does literally nothing, or just bugs my output.
-
What solutions have you tried so far? _G, that didn’t work because for some reason it doesn’t transfer from server to client. I tried a Module Script, but that just says it can’t require it or doesn’t say anything at all. I’ve also tried various different ways of formatting the script and Module Script.
This is the code in my server script:
local RS = game.ReplicatedStorage
local event = RS.IncreaseGenLocal
local event2 = RS.IncreaseGenServer
require(17422087856)
function OnFired()
print("client signal recieved, increasing counter and sending signal")
require(17422087856).counterTableThing.count = require(17422087856).counterTableThing.count + 1
wait(0.5)
event2:FireAllClients()
end
event.OnServerEvent:Connect(OnFired)
This is my local script in Starter Player Scripts:
workspace.Generator1:WaitForChild("button")
script.Parent = workspace.Generator1.button.ClickDetector
local cd = script.Parent
local b = script.Parent.Parent
on = false
local RS = game.ReplicatedStorage
local IG = RS.IncreaseGenLocal
local function onClicked(player)
b.Color = Color3.new(0.145098, 0.972549, 0)
on = true
IG:FireServer()
print("ok, click detected, sending to server")
end
-- Connect the function to the MouseClick event
clickDetector.MouseClick:Connect(onClicked)
This is the script that handles the GUI:
local plr = game.Players.LocalPlayer
local plrgui = plr.PlayerGui
local event = game.ReplicatedStorage.IncreaseGenServer
function GenSwitch()
wait(0.5)
print("signal recieved updating gui")
plrgui.GenCount.TextLabel.Text = "Generators Enabled: "..require(17422087856).counterTableThing.count.."/9"
local newgui = Instance.new("ScreenGui")
newgui.Parent = plrgui
local txtlab = Instance.new("TextLabel")
txtlab.Parent = newgui
txtlab.Font = "Creepster"
txtlab.Text = "Congratulations! A new generator has been enabled!"
wait(5)
newgui:Destroy()
end
event.OnClientEvent:Connect(GenSwitch)
And this is the bare bones module script I had to upload just to try and get this thing to work:
local counterTableThing = {}
count = 0
return counterTableThing
Please help me. I’ve been trying for hours.