Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Do I Invoke Events From A LocalScript to Be Read by Another LocalScript?

Hey,

So I was making a loading menu for my game and I was trying to make a loading screen that when you clicked "Play" the camera unblurred and you could load into the game. However, I am getting the error:

OnInvoke is a callback member of BindableFunction; you can only set the callback value, get is not available

My camera script goes like this:

local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local cam = workspace.CurrentCamera
local blur = Instance.new("BlurEffect",cam)
blur.Enabled = true
blur.Size = 2500
cam.CameraSubject = workspace:WaitForChild("CameraPart")
cam.CameraType = Enum.CameraType.Follow

script.Parent:WaitForChild("Load").OnInvoke:Connect(function()
	if game:GetService("RunService"):IsStudio() then print("Received!") end
	repeat
		wait(.1)
		blur.Size = blur.Size - 10
	until blur.Size <= 0
	script.Parent:Destroy()
end)

The button-handling script goes like this:

local play = script.Parent:WaitForChild("play")
local switch = script.Parent:WaitForChild("switch")
local event = script.Parent.Parent:WaitForChild("Load")


play.MouseButton1Click:Connect(function()
	script.Parent.Visible = false
	script.Parent.Parent.Load:Invoke()
	if game:GetService("RunService"):IsStudio() then print("Sent!") end
end)

I'm not really sure what I should do.

INFO: The switch code is because my game has multiple different versions.

Thanks in advance,

RoboZB

1 answer

✓ Accepted answer

You did the OnInvoke wrong you need to set the callback like this:

local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local cam = workspace.CurrentCamera
local blur = Instance.new("BlurEffect",cam)
blur.Enabled = true
blur.Size = 2500
cam.CameraSubject = workspace:WaitForChild("CameraPart")
cam.CameraType = Enum.CameraType.Follow

script.Parent:WaitForChild("Load").OnInvoke = function() --Fixed line.
    if game:GetService("RunService"):IsStudio() then print("Received!") end
    repeat
        wait(.1)
        blur.Size = blur.Size - 10
    until blur.Size <= 0
    script.Parent:Destroy()
end --Remember to remove this ")"

3 comments

0

Can you tell me why you downvoted my answer?

0

I didn't.

0

Oh, im guessing a random person downvoted my answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.