Basically, by touching the coin, I want to increase a value, but to start off, I tohught about doing the print() just do see if it would work, but when I touched the coin, the message does print but I get this warning: https://gyazo.com/98a81db85cd0899303fafc68658fb14d
Do I maybe need a remote function instead of event?
I believe that is self explanatory. You cannot call RemoteEvent::FireServer from a server script. Remotes are meant for client <-> server communication.
it works, i just tried it in studio, also this would require the player but in my code i only am giving a example of how to raise a value, he could easily transfer the player that touched it to the server and have the server raise their leaderstats
I disagree, You shouldn’t even need a remote for this, use a single script in serverscriptservice. Where these coins are spawned (of cores I don’t know your system, but you need one) you should do this:
local Coin = Instance.new("Part");
Coin.Parent = workspace;
Coin.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
--// hit.Parent is your character, just give it a value here.
Coin:Destroy() --// Removing coin after gaining it.
end
end)
Having it as a localscript will make it vulnerable to exploits.
An exploiter could do something like this and abuse that system:
while true do
wait()
remoteevent:FireServer();
end
In record it’s more secure to have this all within a server script. @ekuz0diaaI I get that, I just recommend a better solution.
Is my solution exploitable? Yes, but way less effective as they’d have to teleport to each coin. If you add a debounce to it you’ll be 100% to go with the exploit problem.
yeah, your way is more efficient but i was answering him with the remoteevent thing and how he tried firing it from the server, thats why i used remote events.