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

Script says that passed value is not a function?

So whenever i try to use this the error: Attempt to connect failed: Passed value is not a function?

game.ReplicatedStorage.MudaBeatdown.OnServerEvent:Connect(function(player, enemychar)
	local char = player.Character
	local replicatedstorage = game:GetService("ReplicatedStorage")
	local disabledevent = replicatedstorage:WaitForChild("Disabled")

	disabledevent.OnServerEvent:Connect(enemychar)
end)

Disabled Script:

game:GetService("ReplicatedStorage").Disabled.OnServerEvent:Connect(function(player, truefalse)
	local chr = player.Character
	local disabled = chr.Disabled
	disabled.Value = truefalse
end)

theres also a Value in the serverstorage called "Disabled"

im trying to make it so it called the event and makes the value Enabled with the disabled script

3 comments

0

Can you fix your code? You’re missing an ‘End’ at OnServerEvent, and are also connecting an identical signal with itself?? The :Connect() method takes a function callback argument to run upon the event firing, you’re likely giving it something entirely different. What is Enemychar?

0

enemy char is the enemy's character (like this is a move for example, this isnt all the code the error only bhappens with the disabled)

0

Do i use anything elsre the connect or whatsovever?

1 answer

If I understand your code correctly, the issue is at line 6. In the comment section, you're saying that:

"enemy char is the enemy's character"

disabledevent.OnServerEvent:Connect requires you to pass a callback function to it, otherwise it doesn't know what to do with it. Here's what i believe is going on with your code, you are trying to pass a model, instead of a function. Which is why it's giving you this error.

Attempt to connect failed: Passed value is not a function

game.ReplicatedStorage.MudaBeatdown.OnServerEvent:Connect(function(player, enemychar)
    local char = player.Character
    local replicatedstorage = game:GetService("ReplicatedStorage")
    local disabledevent = replicatedstorage:WaitForChild("Disabled")

    disabledevent.OnServerEvent:Connect(enemychar) -- this is where the error happens
end)

It's currently difficult to give you an solution to your answer since I'm unsure on what you're trying achieve.

1 comment

0

ok let me add some pats more.. theres a remote event in rep storage called Disabled and theres a value in serverstorage called Disabled, theres also a script, lemme just edit the post

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