I'm looking to create combat system so player can't get hurt if he doesn't have tool

I get this error " Workspace.me.Script:2: attempt to index nil with ‘Character’

1 Like

Use it with the task.wait(2) I added and it should work just fine

heres a snippet that will work for you

local function setForcefield(bool)
character.Forcefield.Enabled = bool
end

character.ChildAdded:Connect(function()
if character:FindFirstChild("Glock 17") then
setForcefield(true)
end
end)

-- do the same with the backpack, and also connect ChildRemoving
-- remember to set variables and create a forcefield inside the character when they are added.

if you go along with this idea, make it a local script. Local player does not work with server scripts.

1 Like

yes use a local script

(character limit)

Just realised I didn’t used local script.

1 Like

a local script wont even be the best if you damage the player on the server.

1 Like

I don’t know did I see right, but when player Have Glock 17, he doesn’t need to have max health, if he have Glock 17, health should be normal, and if he doens’t have Glock 17, then he should have max health.

I don’t want to intrude on your conversation, but this is not a good route to take. You should not be using render stepped for this, or setting the players max health to the largest number.

I know what I’m doing. You are definitely intruding our conversation lol. You have to be trolling. I know how to use remote events. I can help him do it if he can explain exactly what he wants correctly

Yes I know, but it’s a huge script to make that only if player get shot, which I don’t know, and in my game you can only die if you get shoot so…

1 Like

If you know what ER:LC is, something like that, if player is not armed he cant be killed, if he is armed he can be killed.

1 Like

just saying that you definitely should not be doing it this way :person_shrugging: if you want your game to be unoptimized then go ahead

I will make this for you and send you the file so you can just ungroup it within your game. Give me 15 minutes please. Thank you

1 Like

Hey, so I used roblox ai scripter and he made me script.

Solution.rbxm (6.6 KB)

Ok but I just made everything for you. Use it. It works good. You have to ungroup everything where it says to ungroup it. Drag each folder into the area it belongs and ungroup.

Thank you so much! I will test it asap

1 Like

Sounds great! Let me know how it works for you. I can send video tutorial if you need any help setting it up

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.