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:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EXPEvent = RR:WaitForChild("EXPEvent")
local character = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character.Parent.Parent.Parent)
if player then
local damage = 100
local x = script.Parent.Parent.Weapon
x.Touched:Connect(function(x)
if x.Parent:FindFirstChild("Humanoid") and x.Parent.Name ~= player.Name then
x.Parent.Humanoid:TakeDamage(damage)
EXPEvent:FireClient(player) -- Sends the RemoteEvent Request
end
end)
end
and then the Script inside ServerScriptStorage:
EXPEvent.OnServerEvent:Connect(function(player)
wait(2)
player.leaderstats.Experience.Value = player.leaderstats.Experience.Value + 10
end)
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!

2 comments
Thank you for this! I knew nothing of Bindable Events/Functions before, but this fixed that. :) Now I just need to get Touch script to stop going so much upon touch, and its all good to go. Thanks again!
And done. :) Many thanks again!