- What do you want to achieve? Keep it simple and clear!
I want my knife throwing system not be exploitable
- What is the issue? Include screenshots / videos if possible!
The issue is that. I dont really know how and if its secure enough
It works as expected. But i don’t want to release a game with a vulnerability obviously
Heres my code atm:
– // Server(Inside tool)
local THROW = game.ReplicatedStorage:FindFirstChild("EVENTS").THROW
local GET = game.ReplicatedStorage:FindFirstChild("FUNCS").GET_MOUSE
local PLAYER = script.Parent.Parent.Parent
script.Parent.Activated:Connect(function()
local POS = GET:InvokeClient(PLAYER) -- GET PLAYERS MOUSE POSITION
if POS then
local INFO = {
["POS_1"] = script.Parent.Handle.Position;
["MOUSE_POS"] = POS.p
} -- CREATE TABLE STUFF
THROW:FireAllClients(INFO) -- FIRE THROW EVENT
end
end)
– // Throwing system(Inside starter player scripts)
local EVENT = game.ReplicatedStorage:WaitForChild("EVENTS", true).THROW
local DAMAGE = game.ReplicatedStorage:WaitForChild("EVENTS", true).DAMAGE
local CLONE = game.ReplicatedStorage:WaitForChild("Handle", true)
local CONNECTION = nil
EVENT.OnClientEvent:Connect(function(TABLE)
local NEW = CLONE:Clone()
NEW.Position = TABLE["POS_1"] -- POSITION 1 IS THE TOOLS HANDLE
NEW.CFrame = CFrame.lookAt(NEW.Position, TABLE["MOUSE_POS"])
NEW.Velocity = NEW.CFrame.lookVector * 100 + Vector3.new(0, 40, 0)
NEW.Parent = game.Workspace
CONNECTION = NEW.Touched:Connect(function(HIT)
if HIT.Parent:FindFirstChild("Humanoid") then
DAMAGE:FireServer(HIT.Parent.Humanoid) -- IF WE TOUCHED A HUMANOID. TELL THE SERVER TO DAMAGE IT
end
end)
end)
– // Mouse function(Inside starter player scripts also)
local FUNC = game.ReplicatedStorage:WaitForChild("FUNCS", true).GET_MOUSE
local PLAYER = game.Players.LocalPlayer
local MOUSE = PLAYER:GetMouse()
FUNC.OnClientInvoke = function()
return MOUSE.Hit -- RETURN PLAYERS MOUSE
end
Any help is higly appreciated as always !!