How to make a shield for the player

As the title says, I want to make a shield which, when the player presses a key, the shield surrounds the player, I would take care of that, but what I want is that if the player shoots from inside the shield to outside the shield, then it goes through the shield. bullet but if another player shoots from outside the bullet will not go through I think it would be with some cancollide or something like that

1 Like

You could store the owner of the shield and the bullet and add a check to ignore bullet hits on shields that are your own (bullet owner == shield owner), or you could check if the firing point is inside the shield.

1 Like

the language of the title… change it to English so more people can understand

The appropriate title should be
How to make a shield for the player?

A simple approach can be. Using UserInputService for the key input. and Use a Forcefield to protect the user.

I havent tested this code yet since i write it within here. (Local script- It’s handy to use a remote event to make the shield spawn on the server but its an example)

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()

UIS.InputBegan:Connect(function(input, gp)
    if gp then return end
    if input.KeyCode == Enum.KeyCode.Q then -- For example Q.
        local forceField = Instance.new("ForceField")
        forceField.Visible = true
	    forceField.Parent = character
    end
end)

It’s eye catching ngl :wink:

Also, as @BobbieTrooper said, use forcefields to create your shield

UIS.InputBegan:Connect(function(input, gp)
    if gp then return end
    if input.KeyCode == Enum.KeyCode.Q then
        local forceField = Instance.new("ForceField")
        forceField.Visible = true
        forceField.Name = "Shield"
	    forceField.Parent = character
    end
end)

UIS.InputEnded:Connect(function(input, gp)
    if gp then return end
    if input.KeyCode == Enum.KeyCode.Q then 
          character:FindFirstChild("Shield"):Destroy()
    end
end)
1 Like

U tweeked it a little but that should work.

1 Like

non-english is eye catching? what if you only know english and russian and you found french?

like in Furious jumper

1 Like

the reason its eye catching is because its not the general style of devforum threads. the languages a subject knows are irrelevant here.

1 Like

@ValtryekRBLX has already answered your question :smiley: