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

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

Asked by
obcdino 113
6 years ago

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?

0
It might be because of Filtering Enabled. But idk cause I am not a good scripter. dadysherwin2 155 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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)

0
Also, you may want to check if the object that touched whatever is a character. Operation_Meme 890 — 6y
0
Apologies for my error, I learned from my mistake of explaining. Sorry again liteImpulse 47 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago

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)
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. liteImpulse 47 — 6y
0
This is wrong. You're supposed to send the player, not the character as an argument. Operation_Meme 890 — 6y

Answer this question