Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why the error? I see nothing wrong (im brand new to scripting)

Asked by 4 years ago

The error:

Players.spradhan13.PlayerGui.ScreenGui.Frame.TextButton.LocalScript:1: attempt to call a RBXScriptSignal value

The local script in my text button:

script.Parent.MouseButton1Down(function()
    game.StarterGui.ScreenGui:Destroy()
end)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The reason as to why you are getting an attempt to call a RBXScriptSignal value, is because you aren't connecting the MouseButton1Down function. Without connecting it, roblox has no way to tell.

You would want it to do it like this:

script.Parent.MouseButton1Down:Connect(function()
    game.StarterGui.ScreenGui:Destroy()
end)

Also, keep in mind that you cannot actually destroy the GUI via this script, because you are trying to destroy it via the StarterGui which isn't connected to the player. You would want to use PlayerGui Instead, as that IS connected to the player

Here is how you would do it:

local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

script.Parent.MouseButton1Down:Connect(function()
    PlayerGui.ScreenGui:Destroy()
end)
Ad

Answer this question