-
What do you want to achieve?
I Would like to make an admin panel where I can change the time of day. -
What is the issue?
I get an error saying “Attempt to call a nil value” regardless of the fact that I’m calling a value from a NumberValue -
What solutions have you tried so far?
I’ve looked here on the forum and other places, and I couldn’t find any situations similar to mine. Other situations encompassed other concepts that have no relation to my scripts
As I stated above I am trying to make an admin console where I can change the time of day from a GUI button (I have the button part working). When I click the button, the function seems to go through, but I get an error in the output that says: “Attempt to call a nil value” and I’ve been stumped for a while now.
The local script (where the player presses the button and then a signal is sent to the remote event)
function leftClick()
print("Left mouse click")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("TimeChange")
local Time = 330 --Sunrise time
-- Fire the remote event
remoteEvent:FireServer(Time)
end
script.Parent.MouseButton1Click:Connect(leftClick)
The server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("TimeChange")
local Timeval = script.Parent:WaitForChild("Timeval")
-- Create a new part
local function ChangeTime(Time)
print(Time)
Timeval.Value = Time
end
-- Call "onCreatePart()" when the client fires the remote event
remoteEvent.OnServerEvent:Connect(ChangeTime())