Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm trying to use Instance.new('ForceField') but my player still TakeDamage(30), how to stop?

The forcefield doesn't stop damage taken even when ``force.Visible = true

local function spawnShield()
	local playerCFrame = nil
	shield = replicatedStorage:WaitForChild('Shield'):Clone()
	shield.Parent = game.Workspace
	force = Instance.new('ForceField')
	force.Visible = false

	force.Parent = player.Character.Humanoid.Parent
	runService:BindToRenderStep('shield',1,function() -- fake shield that follows the player
		playerCFrame = player.Character.HumanoidRootPart.CFrame
		shield.CFrame = playerCFrame * CFrame.Angles(0,0,math.rad(90))
	end)
end

local function destroyShield()
	runService:UnbindFromRenderStep('shield')
	shield:Destroy()
	force:Destroy()
end


uis.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		debounce,hitBool = false,false
		playslash = player.Character.Humanoid:LoadAnimation(blockAnim)
		playslash:Play()
		spawnShield()
	end
end)

uis.InputEnded:connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		debounce = true
		intValue.Value = 0
		playslash:Stop()
		if shield ~= nil then
			destroyShield()
		end
	end
end)

1 answer

If the client creates the ForceField and the server does damage., the client still gets damaged, because the server doesn't know the player has a ForceField. In order to fix this, you need to run the spawnShield function on the ServerSide.

This discussion is preserved as it was. New answers, comments, and votes are closed.