The problem: I created a function inside a server script (in ServerScriptService) that gives the player 10 points. The function is fired by a remote that’s triggered from a local script example - (player use tool … event fired). The problem is that then the event is fired, not only the player gets their points, but also all the other players in the session.
Just going to point out that doing things like that is very wrong (remote securing wise). You should NEVER trust the client. The amount and level both should be decided by the server, not the by the client. You most probably shouldn’t even create a remote event that just adds money without any checks, the exploiter can simply fire it again and again.
local function GrappleToPosition(position)
-- make sure the character exists
if not character then
return
end
-- dont allow grappling while already grappling
if grappling then
return
end
-- fire remote so the server can replicate the effect
GrappleRemote:FireServer(position)
moneyPay:FireServer() ---- **Here** ----
print(position)
grappling = true
-- play the grapple effect on the client
GrappleEffect:Play(character, position, Grapple.CastTime, Grapple.TravelTime)
-- ez camera tween for more impact
local cameraInfo = TweenInfo.new((Grapple.CastTime + Grapple.TravelTime - (game.Players.LocalPlayer.leaderstats.Speed.Value / 100)) / 2, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0, true)
local cameraTween = Services.TweenService:Create(Camera, cameraInfo, {FieldOfView = Camera.FieldOfView + 30})
cameraTween:Play()
-- cast
-- play the cast animation
animations.Cast:Play(0.1, 1, 1/(Grapple.CastTime * 2))
-- tween the character into position, keeping them floating in the air
local castInfo = TweenInfo.new(Grapple.CastTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local castTween = Services.TweenService:Create(root, castInfo, {CFrame = CFrame.new(root.Position, position)})
castTween:Play()
castTween.Completed:Wait()
-- travel
-- calculate the landing position and tween to it
local direction = (position - root.Position)
local travelCFrame = CFrame.new(position + Vector3.new(0, 4, 0), position + Vector3.new(direction.X, 4, direction.Z))
local travelInfo = TweenInfo.new(Grapple.TravelTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local travelTween = Services.TweenService:Create(root, travelInfo, {CFrame = travelCFrame})
travelTween:Play()
travelTween.Completed:Wait()
-- land
-- switch to getting up in case we tripped somehow
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
grappling = false
end
I highly recommend to not have a remote that directly alters player money, as exploiters can easily give themselves any amount of money.
Instead, for interactions tell the server that a client as performed an interaction, say for example they’ve sold an item in a shop. Verify that the player is allowed to sell that item, that the item exists in that player’s inventory, and check the value of that item all on the server and change the money from there.