So I'm trying to hurt a player but the player isn't getting hurt
There are no errors, Filtering Enabled is on, The bullet fires and the module script fires.
Local script:
local bullet = shootbullet(shooter.CFrame.p, mouse.Hit.p) local damage = math.random(dmgmin,dmgmax) bullet.Touched:connect(function(hit) if hit.Name == "Head" then damage = damage * 3 end globmod:hurt(hit.Parent,damage,game.Players.LocalPlayer.Name) end)
Module script
local runs = {} function runs:hurt(plrname,amount,username) if plrname.Parent:FindFirstChild("Humanoid") and plrname.Parent.Name ~= username then plrname.Parent.Humanoid.Health = plrname.Parent.Humanoid.Health - amount end end return runs
With FilteringEnabled, it basically makes all your local scripts run in their own little world. Which you can take advantage of, and make really neat things. Now, because of this new world being local to the player, that means nothing outside of your computer will see a change your computer made/changed (including other players).
Remote events
This leaves us with remotes. A remote (in ROBLOX) is something that allows communication between all kinds of scripts. We can use the remote event, to command the server to do something a client tells it to do.
Example
I have a pretty good example of how this all works, in my uncopylocked place called "Remote event example" you can check out here:
http://www.roblox.com/games/286802910/Remote-event-example
Now, let's say we have a remote event in the ReplicatedStorage called "Remote". And we have a server script inside the ServerScriptService, that says this:
local RepStorage = game:GetService'ReplicatedStorage' local Remote = RepStorage:WaitForChild'Remote' -- You can read about how to use these arguments in my uncopylocked place i provided above. Remote.OnServerEvent:connect(function(Client, Request, Value) if Request == 'damage' then -- Code here end end)
And now we can modify your code to look like this:
local bullet = shootbullet(shooter.CFrame.p, mouse.Hit.p) local remote = game:GetService'ReplicatedStorage'.Remote local damage = math.random(dmgmin,dmgmax) bullet.Touched:connect(function(hit) if hit.Name == "Head" then damage = damage * 3 end remote:FireServer('damage',damage) -- We may need to pass more arguments as well end)
Hope this helped, if you have any questions let me know.