So i have a spell system that work like this (example for fireball spell):
Client FiresServer. Server checks if player has this type of spell and if so do the function for this spell that includes visualization and checking if spell hit something.
After reading some topics i decided to remake my system to do like this (example for fireball spell):
Client InvokesServer. If server sees spell that client want to use then return true if no false. If server returned true, client do the visuals and if it touched something client fires server and server checks if it really touched something, if so it will deal damage.
The problem is i have no idea how could i check on server if it really touched, since i create and move fireball from each client individually. Also let me know if theres something i want to do and its wrong.
I think they can. For example an exploiter used spell and then he can just change the fireballs position to position inside another player and then server will believe it and damage the innocent player (i might be wrong tho)
The problem with playing it on server is that it will look not smooth. And to show it other players do FireAllClients() and then every player visualize it for himself.
I already explained it, but a bit bad (im sorry for that)
Yes you’re right. But as a matter of fact accomplishing that high leve of exploiting is practically impossible unless you know the exact names and locations of the events fireballs etc.
It’s just better to not worry so much about exploiters.
As for your question, the only way you can check from the server is launching the fireball invisibly from the server and check if the touch position is same for the client and the server as well.
This advice isn’t useful at all; there are definitely exploiters that will do this. It’s not too difficult.
What you could do is; grab the origin position of the fireball (Fire it when the fireball event is sent (NOT THE DAMAGE)) and then cast a ray or something similiar from that point into the direction of the fireball. If it hits something, deal damage.
So, I made that fireball is created in each client individually, but the problem is i have no idea how could i check if it touched something on server.
Heres is how i did it before:
local c = true
for _, v in pairs(game.Workspace.Effects:GetChildren()) do
if v.Owner.Value == NPC then
c = false
break
end
end
if c then
local skill, part = require(game.ServerStorage.Spells[NPC.Type.Value])(NPC, p.Character)
if skill == "hit" then
local pla = game.Players:GetPlayerFromCharacter(part.Parent)
if pla then
--Deal Damage
end
end
end
So if player near NPC it will fire then if fireball still “alive” don’t fire new one, if it gone then fire new.
Now i do like this:
local c = true
for _, v in pairs(game.Workspace.Effects:GetChildren()) do
if v.Owner.Value == NPC then
c = false
break
end
end
if c then
game.ReplicatedStorage.RemoteEvent:FireAllClients("ReproduceSpell", NPC.Type.Value, NPC, p.Character)
end
The problem with new one is since i FireAllClients() how could i tell if something touched? If i do that every client will send their result, will this be a chaos? Or should i choose a specific client (like the one who is being attacked by NPC) that should response?
What if every client will send their result (if it hit or not) and then on server i will check which results are the most. I don’t think there will be most of the players are exploiters so most of the results should be not cheated.
This is the idea i came to. (I know i shouldn’t make it so client can choose what to do, but i simply don’t know how to do it other way)
Just let it happen. Let all the clients do their own thing. if the projectile hits something on the client let it be visualized. It doesn’t matter. Just make a hitbox on the server that is invisible and has the same trajectory as the projectiles on the client and that should be the one doing the damage. You can take it steps further by creating an ID system for the moves so you can keep track of the specific move between server and client and make client visualize the position of hit that took place on the server. idk if that made sense but yeah.