How to make an give you cash on kill?

I mean the hierarchy, the type of script, the actual script, and output (if applicable)

3 Likes

Here you go.
image


image

2 Likes

Ah well for starters - that’s not adjusted to FilteringEnabled (which is now forced on by default - but was defaulted to off when this tutorial was made).

So you should move some of the code over to a Server Script, and send from the client the position to fire from.

Just handle it on the server and it should be good.

2 Likes

So I have to test it on the game itself?

2 Likes

umm no - the game is separated into Server and Client. The server is the host of the game, while the client is just an object within the game. The server sends the client all of the world data and the client renders it to the player.

Check out the article on RemoteEvents/Functions for a more in-depth explanation.

2 Likes

or what do you mean by server script

2 Likes

I don’t get anything of this. lol

2 Likes

Roblox uses a client-server model. Local Scripts reside on the client, while Scripts reside on the server.

I’m sorry I really can’t explain all of this to you and you have to figure this stuff out for yourself. If you still can’t comprehend this, I’d suggest searching the DevForum, Youtube, and other sources. Going back to your original question, you can use any of the methods/tutorials mentioned above. Do try to learn for yourself, as we can’t write code for you. Pseudocode is ok, but I can’t do much for you other than that.

3 Likes

use remote events if you want to damage the zombies.

2 Likes

Thank you, so if I put a remote event in the zombie model any gun woumd work on the zombie?

1 Like

no, what i mean is you should use remote events to damage the zombie, because it’s currently client only.
like:
On localscript

local remote_events = game.ReplicatedStorage.RemoteEvents
local damage = 10
local target = workspace.Zombie -- change the target to the zombie, you can use raycast or Region3
remote_events:FireServer(damage,target)

On Normal Script

local remote_events = game.ReplicatedStorage.RemoteEvents
remote_events.OnServerEvent:Connect(function(player,damage,target)
      target.Humanoid:TakeDamage(damage)
end)

i suggest you learn remote events and remote function so you can make a gun, i watch AlvinBlox tutorials to understand how to use remote events and remote functions.
EDIT : And yeah this script is very risky because it handles damage on the client, which mean exploiters can easily exploit your game, but this is just an example of how remote events work.

3 Likes

Does the script have to be in the zombie and the remote event too? I’ll start learning about it when I’m home. @eyrtuiop232

1 Like

Tidbit: don’t let clients be authoritative of damage. The remote as it stands now can be fired against any instance of the class Humanoid to create a kill all script both for players and NPCs. Be sure to implement some kind of security measures here.

1 Like

You may have different leader stats say you leader stat is money and you’ve written down coins somewhere that might be it.

1 Like

Or just use warbound guns and make a lock tool script so that you don’t realease the gun.

1 Like

Do not set the local damage = 10 in local script, exploiters can edit the damage if local script has it.

how they can edit local variables?