Question about RemoteEvents from Script to Server?
Hello,
I have a Script that's held by a Part, attached to a part inside the Player, when it touches an opposing player, it should both do damage, and send a RemoteEvent. It does the damage, but when it sends the RemoteEvent, its not receiving the request correctly. I think I'm getting the syntax wrong here.
Question: Is FireClient () and OnServerEvent:Connect(function() the correct things to be using here to send the request from a Script, not a LocalScript, to another script on the Server?
Abbreviated Script inside the Part:
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local EXPEvent = RR:WaitForChild( "EXPEvent" ) |
04 | local character = script.Parent.Parent |
05 | local player = game.Players:GetPlayerFromCharacter(character.Parent.Parent.Parent) |
10 | local x = script.Parent.Parent.Weapon |
11 | x.Touched:Connect( function (x) |
12 | if x.Parent:FindFirstChild( "Humanoid" ) and x.Parent.Name ~ = player.Name then |
13 | x.Parent.Humanoid:TakeDamage(damage) |
14 | EXPEvent:FireClient(player) |
and then the Script inside ServerScriptStorage:
1 | EXPEvent.OnServerEvent:Connect( function (player) |
3 | player.leaderstats.Experience.Value = player.leaderstats.Experience.Value + 10 |
I'm not getting any errors, except when I tried changing the OnServerEvent to OnClientEvent and it told me I could only do that from client scripts.
Thanks!