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

How to get RemoteEvent working properly?

Asked by 6 years ago
Edited 6 years ago

Workspace: Localscript>ClickDetector>Part

ReplicatedStorage: RemoteEvent

ServerScriptService: Script

The localscript:

script.Parent.MouseClick:Connect(function()
    game.ReplicatedStorage.PartClicked:FireServer()
end)

The script:

game.ReplicatedStorage.PartClicked.OnServerEvent:Connect(function()
    print("Hello")
end)

I can't seem to figure out/understand why it won't work.

2 answers

Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
6 years ago
Edited 6 years ago

MouseClick() can only be handled using a script. See the description on ClickDetectors

So you don't need a remote event at all to check when a player clicks the part.

In the Script

game.Workspace.Part.ClickDetector.MouseClick:connect(function(playerThatClicked)
    print("Hello "..playerThatClicked.Name.."!")
end)

--Would Print:
--Hello xPolarium!
Ad
Log in to vote
-1
Answered by
oSyM8V3N 429 Moderation Voter
6 years ago
Edited 6 years ago

It should be like this,

REGULAR SCRIPT

local Event = game:GetService("ReplicatedStorage").PartClicked

script.Parent.MouseClick:Connect(function()
Event:FireServer()
end)

SERVER SCRIPT

local Event = game:GetService("ReplicatedStorage").PartClicked

Event.OnServerEvent:Connect(function()
print("Hello")
end)
0
Still doesn't work because it's the same thing he has. Reason whyyy it doesn't work is because MouseClick() can't be used in a local script. xPolarium 1388 — 6y
0
true,i fixed it oSyM8V3N 429 — 6y

Answer this question