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

Attempt to call an RBXScriptSignalValue?

I'm trying to make it so that when you input a key on the client, it will play the sound to the rest of the server. Here is my code and error:

Local Script:


local Sound = script.Sound
local head = script.Parent.Head
player.KeyDown:connect(function(key)
	game.ReplicatedStorage.RemoteEvents.Sound:FireServer()
Sound:Play()

Server Script
game.ReplicatedStorage.RemoteEvents.Sound.OnServerEvent(function(Sound)
	Sound.Parent = workspace
	Sound:Play()
end)

The error code:


 10:28:19.760 - ServerScriptService.ReplicateSound:1: attempt to call a RBXScriptSignal value

####Re-edited by JesseSong!

3 comments

0

Hi! Please put the code in a codeblock so we can understand it more.

0

In the server script on line one you forgot to write :Connect, so it should be

game.ReplicatedStorage.RemoteEvents.Sound.OnServerEvent:Connect(function(Sound)

Also you better not use :connect as it's deprecated, use :Connect for new work.

0

2 answers

Simple! You did not use Connect, RBXScriptSignal is just a fancy name for the signal object, you didn't call the method on it and instead tried to call it like a function! Try this:

--Client script
local Sound = script.Sound
local head = script.Parent:WaitForChild("Head")
player.KeyDown:connect(function(key)
	game.ReplicatedStorage.RemoteEvents.Sound:FireServer()
	Sound:Play()
end)

--Server Script
game.ReplicatedStorage.RemoteEvents.Sound.OnServerEvent:Connect(function(Sound)
    Sound.Parent = workspace
    Sound:Play()
end)

Quite simple actually!

You called a function instead of a method

just add

:Connect

and you're good to go

Code:

local Sound = script.Sound
local head = script.Parent.Head
player.KeyDown:connect(function(key)
    game.ReplicatedStorage.RemoteEvents.Sound:FireServer()
Sound:Play()

Server Script
game.ReplicatedStorage.RemoteEvents.Sound.OnServerEvent:Connect(function(Sound)
    Sound.Parent = workspace
    Sound:Play()
end)

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