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

Why isn't my remote isn't working, and no error comes up?

This code fires the remote when you touch a part: (Server script)

script.Parent.Touched:connect(function(hit)
    game.ReplicatedStorage.Remotes.FeedTheBeliever:FireClient(hit)
end)

This code is what happens when you fire the remote: (Local script)

eat = game.ReplicatedStorage.Remotes.FeedTheBeliever


eat.OnClientEvent:connect(function(hit)
    print(hit.Name)
end)

No errors, and I don't know why this is going on. I tried looking in the wiki, but that was no help. Any suggestions?

1 comment

0

It might be because of Filtering Enabled. But idk cause I am not a good scripter.

2 answers

✓ Accepted answer

This is similar to what litelmpulse answered. The only thing he got wrong was that you're supposed to send the player, not the character, as the argument.

So, here is the serverscript:

script.Parent.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    game:GetService("ReplicatedStorage").RemoteEvent:FireClient(player, hit)
end)

2 comments

0

Also, you may want to check if the object that touched whatever is a character.

0

Apologies for my error, I learned from my mistake of explaining. Sorry again

Server Side

script.Parent.Touched:Connect(function(hit)
	local player = hit.Parent
	game:GetService("ReplicatedStorage").RemoteEvent:FireClient(player, hit)
end)

Client Side

game:GetService("ReplicatedStorage").RemoteEvent.OnClientEvent:Connect(function(hit)
	print(hit.Name)
end)

2 comments

0

player was so that it can fire the event, since it requires a player we are firing to. Now the function in the local script should print whatever touched it.

0

This is wrong. You're supposed to send the player, not the character as an argument.

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